Reputation: 6255
Get data ordered by document Id in Firestore by Javascript
In Andorid, I can use the query go to specific documents
mQuery = docRef.whereEqualTo("name", name)
.whereEqualTo("valid",true)
.orderBy(FieldPath.documentId())
.startAt(lastDocId)
.limit(LIMIT);
It works, but in Javascript, I try to copy a similar query, it didn't work.
var db = firebase.firestore();
var goQuery = docRef.where("name", "==", name)
.where("valid", "==", true)
.orderBy(db.FieldPath.documentId())
.startAfter("id0070")
.limit(LIMIT);
It give a error:
Uncaught TypeError: Cannot read property 'documentId' of undefined at HTMLButtonElement.document.getElementById.onclick
Any idea? Thank you for your help.
Upvotes: 13
Views: 12370
Reputation: 6255
By trial and error, the correct grammar is
var goQuery = docRef.where("name", "==", name)
.where("valid", "==", true)
.orderBy(firebase.firestore.FieldPath.documentId())
.startAfter("id0070")
.limit(LIMIT);
firebase.firestore.FieldPath.documentId()
Upvotes: 26