I have this collection in cloud Firestore named ('goal'), and so far there are two documents 'Nov 10, 2019', and 'Nov 11, 2019'. How do I get the document that was first created (Nov 10,2019) programmatically?
0
votes
Order by dateAdded, limit 1. You'll have to build a reference to the specific goal collection you want, since it seems to be a subcollection under documents of users.
- Doug Stevenson
Hello, I do not understand the Order by dateAdded, here is my code so far: var document = await Firestore.instance.collection('users').document(userData[index].uID).collection('goal').orderBy('dateAdded'); I can't seem to add 'limit 1' since it throws some errors
- Allen Andre Indefenzo
Please edit the question to show the exact code that isn't working the way you expect, as well as the specific errors. We should be able to reproduce exactly what you're seeing.
- Doug Stevenson
1 Answers
1
votes
Thanks to @Doug Stevenson, I managed to arrive at the answer!
var document2 = await Firestore.instance
.collection('users')
.document(userData[index].uID) // I store my user's UID locally in a FutueBuilder func hence the index
.collection('goal')
.orderBy("dateAdded")
.limit(1)
.getDocuments()
.then((QuerySnapshot a) {});
