Reputation: 407
the collection name is the specific user id i want to retrieve data for the specific user. how can i do that. this is the screen shot of my database 1 i tried this code but it return only the 1st collection because of the array
StreamBuilder(
stream: Firestore.instance.collection("/userdata").snapshots(),
builder: (context, snapshot) {
gnickname = snapshot.data.documents[0]["Nickname"];
gphotourl = snapshot.data.documents[0]["photoURL"];})
Upvotes: 0
Views: 6072
Reputation: 899
To get a specific record based on the uid use, in your case, the following code:
var userData = Firestore.instance.collection("/userdata").document("uid").get();
userData
is a DocumentSnapshot
so use userData.data
object to get the key/value pairs.
Upvotes: 1
Reputation: 1814
To get specific user you can try:
Firestore.instance.collection('your_collection').document('your_id').snapshots()
Upvotes: 0
Reputation: 3451
You can do it like that for first collection
StreamBuilder(
stream: Firestore.instance.collection("/userdata").snapshots(),
builder: (context, snapshot) {
gnickname = snapshot.data.documents.first["Nickname"];
gphotourl = snapshot.data.documents.first["photoURL"];})
Upvotes: 0