google-cloud-firestore

Firestore transaction with multiple get

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-10 07:33:27
问题 I'm trying to run a transaction with a variable number of read operations. I put the read () operations before than update (). Reading the Firestore doc on https://cloud.google.com/firestore/docs/manage-data/transactions "A transaction consists of any number of get() operations followed by any number of write operations such as set(), update(), or delete()" And When using transactions, note that: Read operations must come before write operations. A function calling a transaction (transaction

Add timestamp in Firestore documents

心不动则不痛 提交于 2020-05-10 07:12:53
问题 I'm newbie to Firestore. Firestore docs says... Important : Unlike "push IDs" in the Firebase Realtime Database, Cloud Firestore auto-generated IDs do not provide any automatic ordering. If you want to be able to order your documents by creation date, you should store a timestamp as a field in the documents. Reference: https://firebase.google.com/docs/firestore/manage-data/add-data So do I have to create key name as timestamp in document? Or created is suffice to fulfill above statement from

Add timestamp in Firestore documents

我只是一个虾纸丫 提交于 2020-05-10 07:12:10
问题 I'm newbie to Firestore. Firestore docs says... Important : Unlike "push IDs" in the Firebase Realtime Database, Cloud Firestore auto-generated IDs do not provide any automatic ordering. If you want to be able to order your documents by creation date, you should store a timestamp as a field in the documents. Reference: https://firebase.google.com/docs/firestore/manage-data/add-data So do I have to create key name as timestamp in document? Or created is suffice to fulfill above statement from

Firestore array contains query not returning result [duplicate]

半世苍凉 提交于 2020-05-09 17:16:10
问题 This question already has answers here : Google Firestore: Query on substring of a property value (text search) (14 answers) Closed last month . I have around 30 records in collection todos , almost 25 of them contains the word work . Now when I am trying to use array-contains it doesn't return anything. Here is my query code: firebase.firestore().collection("todos") .where('Workdesc', 'array-contains', 'work') .get() .then(querySnapshot => { querySnapshot.forEach(function(doc) { // doc.data(

Firestore billing for writes that have no effect [duplicate]

寵の児 提交于 2020-05-09 17:15:18
问题 This question already has answers here : Document Updates - Do updates with no changes still cost 1 write? (2 answers) Closed last month . Im trying to find out how firebase is billing write operations. In the billings documentation I could not find a clear definition of when a write is counted. Lets say I run a set query with the exact same data of the original documen, such that the document won't be affected, will this be billed as a write operation? When I run my query with the console

Firestore billing for writes that have no effect [duplicate]

牧云@^-^@ 提交于 2020-05-09 17:15:09
问题 This question already has answers here : Document Updates - Do updates with no changes still cost 1 write? (2 answers) Closed last month . Im trying to find out how firebase is billing write operations. In the billings documentation I could not find a clear definition of when a write is counted. Lets say I run a set query with the exact same data of the original documen, such that the document won't be affected, will this be billed as a write operation? When I run my query with the console

Firestore billing for writes that have no effect [duplicate]

為{幸葍}努か 提交于 2020-05-09 17:13:53
问题 This question already has answers here : Document Updates - Do updates with no changes still cost 1 write? (2 answers) Closed last month . Im trying to find out how firebase is billing write operations. In the billings documentation I could not find a clear definition of when a write is counted. Lets say I run a set query with the exact same data of the original documen, such that the document won't be affected, will this be billed as a write operation? When I run my query with the console

Updating collection in Firebase returns error “found nil while unwrapping optional value”?

瘦欲@ 提交于 2020-05-09 17:06:52
问题 I'm making this app where the idea is that you create a profile, add your dogs, and then update a timer on them (when they last ate, took a walk, etc). I'm having some issues with Firebase though. I managed to have the user add dogs to their account, but now that I'm trying to update some values on a certain dog the app crashes with a "Unexpectedly found nil while unwrapping an Optional value" which seems to be due to Firebase. My Database contains the user, their dogs and a collection of the

What is the exact size of a Firestore document?

僤鯓⒐⒋嵵緔 提交于 2020-05-09 16:15:55
问题 The docs says that the size of a document is composed of: document name size The sum of the string size of each field name The sum of the size of each field value 32 additional bytes The following document example: "type": "Personal" "done": false "priority": 1 "description": "Learn Cloud Firestore" Has the size of 147 . Question: When calculating the size of a document, is there anything else I should care of? Perhaps some metadata? Because when using this calculation, there's for sure

Is it possible to determine the source of an incoming request?

核能气质少年 提交于 2020-05-09 10:27:09
问题 Is it possible to know the hostname of the source of an incoming request to a cloud firestore document? I would like to write a database rule of the form allow write: if request.resource.data.source_host_name == some_predefined_value . This is a web application so I'm trying to find a good way to limit who gets to write to my database without using traditional auth methods. 回答1: That sort of rule is not possible with Cloud Firestore. It also wouldn't be very secure, as it's possible to spoof