Reputation: 43
Im trying to do a group system for a flutter app and I need to store it in firebase, and every group has his own ID, it's called "groupID". How to do programmatically that every new group create has his "groupID" create automatically. Is organized like this:
In other words, how can I do in the code to fill the Groups column?
Upvotes: 1
Views: 214
Reputation: 1405
In Flutter,
DocumentReference docRef = firestore.collection('Groups').document();
print(docRef.documentID);
docRef.setData({JSON Data});
String groupID = 'unique_id'
DocumentReference docRef = firestore.collection('Groups').document(groupID);
print(docRef.documentID);
docRef.setData({JSON Data});
For constraints on document ID - https://firebase.google.com/docs/firestore/quotas#collections_documents_and_fields
Upvotes: 2