I am trying to get the logged-in user info from my firestore database in my react native app. I am new to react native, therefore I don’t know the correct syntax or methodology to do these things with firestore. I’ve read many documentations but they don’t provide information for every situation and instance. here is my code: my AuthProvider.js: my
Tag: google-cloud-firestore
How to return the document data got from firestore using .get() to another function in JS
I have a function that needs some data from firestore and I want to make another function that will get the data and return it to the function calling it The code that I’m trying: Here my logic function needs to use data that is received from the getData function Any suggestions on how to get the data in this
Saving Date to firestore document in Javascript
I have a function that converts date string to Date Then I use as following: But on firebase console, the birthdate is stored as an empty array as the image bellow: What I am doing wrong? Answer convertStringToDate returns a Date object, which if you console log, will show up something like this: If you want to store it as
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
How to do arrayUnion on an array of objects inside another array of objects in firebase firestore?
I have created a comment section in my react app. The comment section has following data structure in the firestore:- If I want to add a new comment I do this by: – Now, what I actually want to do is to do is to add a new reply to the existing comment. But I can’t find any way to
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
Retrieve data from multiple documents from Firestore
I tried a lot of times but I am still not able to retrieve data from multiple documents, The below screenshot shows that I have 3 documents in my collection and my question is how to retrieve data from each of them. I used foreach loop to loop through all the documents but I don’t know how to retrieve data
Add a new image with the existing image list in firestore database
I have already two images in the firestore database, I am trying to add a new image to this list? How can I add a new image to the existing image list? Answer To add another array to the postImg, you can: Also see the Firebase documentation on adding items to an array.