'Create a collection inside users document: Cloud Firestore
I'm trying to create an "Orders" collection inside the user document so that I can be able to get the orders that a specific user has made. This is what I tried:
if(firebaseUser!=null){
String userID= firebaseUser.getUid();
DocumentReference userDoc= db.collection("users").document(userID);
userDoc.collection("orders").document(model.getMeal_name() + " " + day)
.set(order).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
Log.d(TAG, "Order entry into database");
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
});
}
But it's creating the document in the users collection as opposed to creating it inside a document. What am I doing wrong?
Here's my database screenshot with the new document it created.

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
