My problem is getting the document id from firestore.
How I do fetch Users/documentid/Comments/documentid ?
Data class:
public class BlogPostId {
@Exclude
public String BlogPostId;
public <T extends BlogPostId> T withId(@NonNull final String id) {
this.BlogPostId = id;
return (T) this;
}
}
AddActivity:
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);
}
Unfortunately, there is no way in Cloud Firestore to get the name Mehmet
which exists within the zSNQ...mUUF
document and the name ahmet
which exists within the SinifDevam
document in a single query.
Queries in Firestore are shallow, they only get items from the collection that the query is run against. There is no way to get documents from another top-level collection and or from a subcollections in a single query. Firestore doesn't support queries across different collections in one step. A single query may only use properties of documents in only a single collection.
To solve this, you should add all user objects within a single collection and query it accordingly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.