google-cloud-firestore

Why doesn't firestore onWrite trigger get invoked on firebase cloud functions emulator?

穿精又带淫゛_ 提交于 2021-01-27 20:05:04
问题 I have a firestore with a collection called "chats"; I use the firestore emulator to insert a new document and I am expecting the onWrite trigger to get called while I am running index.js locally on my firebase cloud functions emulator (by running firebase emulators:start ), but it never does. I know that the emulator is connected to the right firestore emulator since I can read the data (see below), I just can't get the trigger to be invoked. // My setup: const functions = require('firebase

How to get Firestore Index Merge to work?

六眼飞鱼酱① 提交于 2021-01-27 15:10:37
问题 I am having trouble using firestore index merging in order to reduce the number of required indices. Consider this example situation: Firestore Collection: test/somedoc { a: '1', b: '1', c: '1', d: '1' } This will cause Firestore to create 4 automatic single field indices on test for fields a to d. Querying this table with a few equality conditions and one unrelated sort: await db.collection('test') .where('a', '==', '1') .where('b', '==', '1') .where('c', '==', '1') .orderBy('d') .get();

How to make the data from Firestore in to a global variable?

醉酒当歌 提交于 2021-01-27 14:33:43
问题 How can I make the value return outside the onSnapshot function? function checkIfExisting(){ const collection = firebase.firestore().collection("audit"); const getCaseID = collection.where("caseID", "==", "00001234"); getCaseID.onSnapshot(function(querySnapshot) { let wordLists = []; querySnapshot.forEach(function(doc) { //get all the scanned words under "word" field in the Firestore Database wordLists.push(doc.data().word); }); console.log("words: ", wordLists);// return a value }); console

Firebase Functions, admin.database().ref(…).get() is not a function

无人久伴 提交于 2021-01-27 14:16:23
问题 I am working on an Android Application and am using firebase as the back end for it. I am trying to get a notification system working that relies on listening to changes in the database. Having problems though as I am getting the following error. Wondered if anyone would be able to help, any extra code can be supplied. Firebase Function 'use-strict' const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase);

Saving image to Cloud firestore

谁说我不能喝 提交于 2021-01-27 14:11:31
问题 How do I save the image to the firebase firestore, when I have uploaded the image to the firebase storage? How do I save the image to the firebase firestore, when I have uploaded the image to the firebase storage? I am supposed to have posts with a title and an image, but I don't know how to do the image part. my code is shown below .... import Foundation import FirebaseFirestore protocol DocumentSerializable { init?(dictionary:[String:Any]) } struct Post { var name: String var content:

Saving image to Cloud firestore

a 夏天 提交于 2021-01-27 14:00:17
问题 How do I save the image to the firebase firestore, when I have uploaded the image to the firebase storage? How do I save the image to the firebase firestore, when I have uploaded the image to the firebase storage? I am supposed to have posts with a title and an image, but I don't know how to do the image part. my code is shown below .... import Foundation import FirebaseFirestore protocol DocumentSerializable { init?(dictionary:[String:Any]) } struct Post { var name: String var content:

Unhandled Rejection in Google Cloud Functions

北城余情 提交于 2021-01-27 13:47:29
问题 I got the following cloud function which works great. It's listening for an update in the real-time database and update Firestore accordingly. Everything is fine, except when my user does not exist yet my Firestore database. This where I need to deal with Unhandled rejection that I see in the Google Cloud Functions log. So see below, in the shortened version of the function, for my db.collection("users").where("email", "==", email).get() how to stop the function to move forward and prevent

Using wildcards in firestore get query

♀尐吖头ヾ 提交于 2021-01-27 12:50:48
问题 I want to create a cloud function in firebase that gets triggered whenever a user logs in for the first time. The function needs to add the UID from the authentication of the specific user to a specific, already existing document in firestore. The problem is that the UID needs to be added to a document of which I do not know the location. The code I have right now doesn't completely do that, but this is the part where it goes wrong. The database looks like this when simplified organisations

Firebase Firestore Web NOT working behind corporate proxy

泄露秘密 提交于 2021-01-27 12:30:42
问题 My computer is behind a corporate proxy. While visiting a website which is using Firebase Firestore, it is not connecting to the firebase servers. I am getting the below error in console. [2018-09-21T10:09:15.854Z] @firebase/firestore: Firestore (5.4.1): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds. This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able

Defining a Firestore query by comparing two document's fields values

妖精的绣舞 提交于 2021-01-27 12:01:39
问题 I'm having my first steps with Cloud Firestore, and I am stuck on this one. I'm looking for a where query to return me values that are >= the limit. [{ 'limit': 100, 'value': 200 }, { 'limit': 50, 'value: 50, }, { 'limit': 95, 'value': 90, }] I am using the Firebase Admin Python SDK in a Cloud Function. Any hints? 回答1: As Alex has explained, there is no way to compare two document's fields values when executing a query with Firestore. One possible approach, would be to save the result of the