- Firebase SDK version: 5.5.0
- Firebase Product: firestore
I'm using Firebase Admin SDK in Firebase Cloud Functions environment. I noticed that firebase.firestore.Query cursor methods, such as startAt, startAfter etc, are not working correctly when called with DocumentSnapshot as argument.
Collection test is populated with the following documents:
a:{ v: "a", sort: 1 }
b:{ v: "b", sort: 0 }
c:{ v: "c", sort: 2 }
Here's my cloud function code:
constdb=admin.firestore();constcoll=db.collection('test');constquery=coll.orderBy('sort');returncoll.doc('a').get().then((snap)=>query.startAt(snap).get()).then((snaps)=>{console.log(snaps.size);});Expected behavior to receive two documents (a and c), instead the following exception is thrown:
Error: Cannot encode type ([object Object]) to a Firestore Value
at Function.encodeValue (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/document.js:669:11)
at Query._buildPosition (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/reference.js:1267:44)
at Query.startAt (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/reference.js:1295:28)
at coll.doc.get.then (/user_code/index.js:20:8)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
I'm using Firebase Admin SDK in Firebase Cloud Functions environment. I noticed that
firebase.firestore.Querycursor methods, such asstartAt,startAfteretc, are not working correctly when called withDocumentSnapshotas argument.Collection
testis populated with the following documents:a:
{ v: "a", sort: 1 }b:
{ v: "b", sort: 0 }c:
{ v: "c", sort: 2 }Here's my cloud function code:
Expected behavior to receive two documents (a and c), instead the following exception is thrown: