java - 我如何获得 blogpostId 火库?
问题描述
我的问题是从 Firestore 获取文档 ID。
我如何获取 Users/documentid/Comments/documentid ?
数据类:
public class BlogPostId {
@Exclude
public String BlogPostId;
public <T extends BlogPostId> T withId(@NonNull final String id) {
this.BlogPostId = id;
return (T) this;
}
}
添加活动:
private String blog_post_id;
Oncreate
blog_post_id = getIntent().getStringExtra("blog_post_id");
btn click
final String descff = icerikedit.getText().toString();
Map<String, Object> commentsMap = new HashMap<>();
commentsMap.put("descff", descff);
commentsMap.put("user_id", current_user_id);
commentsMap.put("timestamp", FieldValue.serverTimestamp());
firebaseFirestore.collection("Users/"+blog_post_id+"/Comments").add(commentsMap).addOnCompleteListener(new OnCompleteListener<DocumentReference>() {
@Override
public void onComplete(@NonNull Task<DocumentReference> task) {
if(task.isSuccessful()){
Toast.makeText(FFicerikAdd.this, "Başarılı efe!", Toast.LENGTH_SHORT).show();
Intent sab=new Intent(getApplicationContext(),FFicerik.class);
sab.putExtra("blog_post_id",blog_post_id);
startActivity(sab);
}
解决方案
不幸的是,Cloud Firestore 无法在单个查询中获取文档中存在的名称和文档中Mehmet
存在的名称。zSNQ...mUUF
ahmet
SinifDevam
Firestore 中的查询很浅,它们仅从运行查询的集合中获取项目。无法从单个查询中的另一个顶级集合和/或子集合中获取文档。Firestore 不支持一步跨不同集合的查询。单个查询只能使用单个集合中的文档属性。
为了解决这个问题,您应该在一个集合中添加所有用户对象并相应地查询它。
推荐阅读
- javascript - 在 href 中获取当前页面 URL
- python-3.x - 即使终端关闭,如何在后台运行python scipt(用户输入后)
- javascript - NodeJS 顺序处理 API 调用,但导致堆栈溢出
- python - 使用多线程(使用 concurrent.futures)的 Python 中的列表追加导致偏移行
- vuetify.js - 在 vuetify 表单上显示计算值的正确方法
- linux - WHM/cPanel - 多个 IP 指向一个根目录
- r - R中的成对栅格比较:替代for循环?
- r - R闪亮路由器重定向到包含参数的URL
- javascript - 网页抓取 Cheerio 和 node js
- python - 如何为文件名添加一个字段,该字段填充从解析的 pdf 中提取的每一行数据的文件名?