google-cloud-firestore

How can I get specific document data from firestore querysnapshot?

不问归期 提交于 2020-01-23 12:04:26
问题 I got a querysnapshot in a function. And want to bring the whole querysnapshot to another function (functionTwo). In functionTwo, I want to get a specific document in the querysnapshot WITHOUT forEach. The specific doc can be changed by different case. ref_serial_setting.get() .then(querysnapshot => { return functionTwo(querysnapshot) }) .catch(err => { console.log('Error getting documents', err) }) let functionTwo = (querysnapshot) => { // getting value const dataKey_1 = "dataKey_1" // Tried

How to trigger firestore cloud functions on update of field value?

扶醉桌前 提交于 2020-01-23 11:42:34
问题 I want to send email to user on update of status field of user to value (true) using firestore and cloud functions. My case : I have a users(collections) which has more documents of userId(documents) and each document contains field and value. One of the field is status: true | false (boolean). I want to send email to that user if status of that user change to true using cloud functions and sendgrid api. users - dOpjjsjssdsk2121j131 - id : dOpjjsjssdsk2121j131 - status : false -

Error: 10 ABORTED: Too much contention on these documents. Please try again

半世苍凉 提交于 2020-01-23 10:17:37
问题 What does this error mean? Especially, what do they mean by : Please try again Does it mean that the transaction failed I have to re-run the transaction manually? From what I understood from the documentation, The transaction read a document that was modified outside of the transaction. In this case, the transaction automatically runs again. The transaction is retried a finite number of times. If so, on which documents? The error do not indicate which document it is talking about. I just get

Error: 10 ABORTED: Too much contention on these documents. Please try again

允我心安 提交于 2020-01-23 10:17:09
问题 What does this error mean? Especially, what do they mean by : Please try again Does it mean that the transaction failed I have to re-run the transaction manually? From what I understood from the documentation, The transaction read a document that was modified outside of the transaction. In this case, the transaction automatically runs again. The transaction is retried a finite number of times. If so, on which documents? The error do not indicate which document it is talking about. I just get

How to efficiently access a firestore reference field's data in flutter?

怎甘沉沦 提交于 2020-01-23 09:29:12
问题 Using similar code as flutter's firestore example, suppose there is a reference field stored in a snapshot document, called: document['userRef'] . First of all, how do I access the data of userRef? Using document['userRef'].get().data or document['userRef'].get().username I wasn't able to access the data. ( NoSuchMethodError: Class 'Future<DocumentSnapshot>' has no instance getter 'data' ) I also tried using document['userRef'].get().then(...) but getting the error: type 'Future<dynamic>' is

How to fix error “Ambiguous use of 'increment'” on iOS Firestore increment()

安稳与你 提交于 2020-01-23 06:10:00
问题 I receive a compiler error when trying to use firebase FieldValue.increment(1) in iOS using swift. The error only says "Ambiguous use of 'increment'" I have updated all my pods to the current versions of all firebase pods used. More specifically I am on Firebase(5.20.2) and FirebaseFirestore (1.2.1). My code (below) is almost exactly the same as the example in the docs Seen at the bottom of this page How can I fix this error and get the app to compile? let docRef = db.collection("metadata")

How to fix error “Ambiguous use of 'increment'” on iOS Firestore increment()

泄露秘密 提交于 2020-01-23 06:09:24
问题 I receive a compiler error when trying to use firebase FieldValue.increment(1) in iOS using swift. The error only says "Ambiguous use of 'increment'" I have updated all my pods to the current versions of all firebase pods used. More specifically I am on Firebase(5.20.2) and FirebaseFirestore (1.2.1). My code (below) is almost exactly the same as the example in the docs Seen at the bottom of this page How can I fix this error and get the app to compile? let docRef = db.collection("metadata")

Firestore schema versioning and backward compatibility with android app to prevent crashes

天大地大妈咪最大 提交于 2020-01-22 19:57:42
问题 Firestore a NOSQL is a Document oriented database. Now how to manage versioning of the data as I use it with Firebase SDK and Android applications? For e.g. let's say I have a JSON schema that I launch with my 1.0.0version of my android app. Later 1.0.1 comes up where I have to add some extra fields for the newer documents. Since I changed the structure to have additional information, it only applies to new documents. Therefore, using this logic, I can see my Android application must be able

How store binary tree nodes in firestore

本小妞迷上赌 提交于 2020-01-22 02:48:08
问题 I want to create a binary tree in react.I am using react-d3-tree component for displaying the tree. For react-d3-tree the data should be of the format const myTreeData = [ { name: 'Top Level', attributes: { keyA: 'val A', keyB: 'val B', keyC: 'val C', }, children: [ { name: 'Level 2: A', attributes: { keyA: 'val A', keyB: 'val B', keyC: 'val C', }, }, { name: 'Level 2: B', }, ], }, ]; How to store data on firestore so that I can retrieve it and get it as the above array format? 回答1: You just

Append to array Firebase

China☆狼群 提交于 2020-01-22 02:42:08
问题 I'm using Firebase and Vuejs to create an database element, which has object array inside. That's how the object looks, and I want to add tasks through the form into the 'moreTasks' tab. I tried using this, but it just creates new entity in the database. db.collection('Tasks').add({ tasker: this.tasker.taskerName }) I also tried checking API but I couldnt understand the refs, because I was using different methods to achieve that goal. creatTask() { db.collection('Tasks').add({ task_id: this