Skip to content
Advertisement

Tag: google-cloud-firestore

share firestore collection paths across admin and web

I’d like to make re-usable functions that get the Firestore Document/Collection reference across web and admin (node.js). for example: This will reduce errors and coordinate changes across both environments. Problem: Admin imports firestore from firebase-admin, and web imports from firebase. I’ve tried making some class/function where I pass in my firestore reference, but it becomes a pain where I have

Firestore: get an array of objects

Is it possible to get an array of objects from Firestore. I tried something like below but I am getting undefined when I tried to log comments[0].comment Answer This returns a QuerySnapshot which contains the DocumentSnapshot of each document that has matched your query. The array of object is a field in your document. You cannot get a single field

Querying multiple collections of firestore using array-contains-any

I am trying query a number of documents in different collections with array-contains-any, by using Promise.all() to get all the documents at once. I’ve checked whether the path is correct, whether the documents exist, whether the key exists in the document and everything is ok. The querySnapshots and snapshots have no data retrieved. At some point of the log says:

Firestore data aggregation of documents

I’m creating an expense tracker app, where the user can set a monthly budget (ie. $3,000) and a field ‘total spending for the month’ would update each time a user adds an expense. How would I do this using Firestore Database? So far, I have the expense record stored in a subcollection inside a document (using user-id) inside a user’s

Advertisement