我的問題是從 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;Oncreateblog_post_id = getIntent().getStringExtra("blog_post_id");btn clickfinal 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); }
1 回答

尚方寶劍之說
TA貢獻1788條經驗 獲得超4個贊
不幸的是,在云計算公司的FireStore沒有辦法得到的名稱Mehmet
在中存在哪些zSNQ...mUUF
文件和名稱ahmet
的范圍內它存在SinifDevam
于一個單一的查詢文檔。
Firestore 中的查詢很淺,它們只從運行查詢的集合中獲取項目。無法在單個查詢中從另一個頂級集合或子集合中獲取文檔。Firestore 不支持一步跨不同集合的查詢。單個查詢只能在使用的文件的屬性只有一個單一的集合。
要解決此問題,您應該在單個集合中添加所有用戶對象并相應地查詢它。
添加回答
舉報
0/150
提交
取消