[Cloud Firestore] [Node SDK] Returning a query with getAll

814 views
Skip to first unread message

Jason Berryman

unread,
Jan 31, 2018, 9:16:09 AM1/31/18
to Firebase Google Group
I'm using getAll to return multiple documents in the Cloud Firestore Node SDK.  However, I'm unable to return a query, without having to go back to using Promise.All (which is much slower).  You can see in the error, that the problem is with index 2 (the query)

Is there support for queries using getAll?

My code
    let firstRef = db.doc('/myCollection/${someID}/someData/${someDataId}');
    let secondRef
= firstRef.collection('nextCollection').doc(anotherId);
    let firstQuery
= secondRef.collection('finalCollection').where('completed', '==', false);

   
// Working, but slow, Promise.All code
   
// let p0 = firstRef.get();
   
// let p1 = secondRef.get();
   
// let p2 = firstQuery.get();
   
// return Promise.all ([p0, p1, p2]).then(response => {

   
return db.getAll(firstRef, secondRef, firstQuery).then(response => {


The error
Error: Argument at index 2 is not a valid DocumentReference. at Object.exports.(anonymous function) [as isDocumentReference] (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/validate.js:86:15) at Firestore.getAll (/user_code/node_modules/firebase-admin/node_modules/@google-cloud/firestore/src/index.js:556:16) at /user_code/myCode.js:172:15 at Object.update (/user_code/myCode.js:147:87) at someRef.get.then.someSnap (/user_code/myFunction.js:91:31) at process._tickDomainCallback (internal/process/next_tick.js:135:7)


Michael Bleigh

unread,
Jan 31, 2018, 7:09:55 PM1/31/18
to fireba...@googlegroups.com
Query fetching and document fetching are quite different, IIUC (someone on the team may well correct me). I don't believe there is any plan to support query fetching as part of getAll.

-Michael

Dolphin ONE Communications


sales: +44 20 3375 4000
support: +44 20 3375 4 247

...or visit http://www.dolphinone.net


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/dfc0d1ec-cf60-4f20-8df1-c763d422798a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Berryman

unread,
Feb 2, 2018, 11:34:45 AM2/2/18
to Firebase Google Group
Thanks for the heads up, Michael.  I did email Clem, but I haven't had a response.  Sam suggested posting here, as he's currently on vacation.

I'm going to change my backend so that I know which document to fetch, rather than querying for it.  Is getAll going to make it into the main Firebase documentation?  At the moment, it's fairly difficult to find.

All the best,

Jason

Michael Lehenbauer

unread,
Feb 12, 2018, 6:32:19 PM2/12/18
to Firebase Google Group
Thanks Jason,

We're intending to add getAll() to the mobile SDKs in the future (right now it's only available in the server SDKs) and I've added a note to make sure we add it to the docs as part of that.

-Michael

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages