google-cloud-firestore

Return nested collection from firestore as object for angularfire2 and firebase

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-18 12:47:08
问题 Let's say you have the following structure: shopping-carts (collection) - shopping-cart 1(doc) -- dateCreated (field) -- items (collection) - shopping-cart 2(doc -- dateCreated -- items . . . So, how would we go about getting the entire shopping-cart(doc) as an ShoppingCart object that we defined as export interface ShoppingCart { items: ShoppingCartItem[] dateCreated: string } afs.doc('shopping-cart/id').valueChanges() only returns the dateCreated afs.doc('shopping-cart/id').collection(

Firestore transactions getting triggered multiple times resulting in wrong data

南楼画角 提交于 2021-02-17 20:55:15
问题 So I have a cloud function that is triggered each time a transaction is liked/unliked. This function increments/decrements the likesCount . I've used firestore transactions to achieve the same. I think the problem is the Code inside the Transaction block is getting executed multiple times, which may be correct as per the documentation. But my Likes count are being updated incorrectly at certain times. return firestore.runTransaction(function (transaction) { return transaction.get(transRef)

Firestore - subcollection query for a specific document

喜欢而已 提交于 2021-02-17 15:51:40
问题 Note: Querying across subcollections is not currently supported in Cloud Firestore. If you need to query data across collections, use root-level collections. When I read the documentation for me it's not clear if it's possible to do something like this: var listsRef = db.collection("users/user1/lists"); var query = listsRef.where("public", "==", true); I can understand that it's not supported if I try to do this: var listsRef = db.collection("users/{userId}/lists"); var query = listsRef.where

Returning name from Firestore?

寵の児 提交于 2021-02-17 07:17:13
问题 I'm trying to return a name after getting it on Firestore, but for some reason it's not working. Here's my code: func getName() -> String { var name = "" db.collection("users").whereField("email", isEqualTo: user.email!).getDocuments { (snapshot, error) in if error != nil { print(error!) } else { for document in (snapshot?.documents)! { name = document.data()["name"] as! String // if I add `print(name) here, it works.` } } } return name } But it returns an empty string :/ I want to return the

Returning name from Firestore?

醉酒当歌 提交于 2021-02-17 07:16:18
问题 I'm trying to return a name after getting it on Firestore, but for some reason it's not working. Here's my code: func getName() -> String { var name = "" db.collection("users").whereField("email", isEqualTo: user.email!).getDocuments { (snapshot, error) in if error != nil { print(error!) } else { for document in (snapshot?.documents)! { name = document.data()["name"] as! String // if I add `print(name) here, it works.` } } } return name } But it returns an empty string :/ I want to return the

Error [FirebaseError]: Invalid document reference. Document references must have an even number of segments,

↘锁芯ラ 提交于 2021-02-17 07:09:37
问题 const firebase = require("firebase"); // Required for side-effects require("firebase/firestore"); // Initialize Cloud Firestore through Firebase firebase.initializeApp({ apiKey: "____", authDomain: "____", projectId: "____" }); var db = firebase.firestore(); var datasetSymptom=[{ "Disease" : [ "edema pulmonary" ], "Symptom" : "Heberden's node" }, { "Disease" : [ "cholecystitis" ], "Symptom" : "Murphy's sign" }, { "Disease" : [ "hemiparesis", "hypertension pulmonary", "transient ischemic

how to edit an array element present in firestore [duplicate]

杀马特。学长 韩版系。学妹 提交于 2021-02-17 07:03:49
问题 This question already has answers here : Flutter: Update specific index in list (Firestore) (1 answer) Flutter: How to update an Array within an Array in the firestore (1 answer) Closed 9 months ago . I have an array of strings present in firestore. I want to edit the string present at a particular index. How can I do this? For example, let the array be ["help","me","please"]; How can I change "help" to "don't help" in flutter? The closest I've gotten to editing the array is adding an element

Add additional data to user profile via firestore functions onCreate

删除回忆录丶 提交于 2021-02-17 07:01:12
问题 I'm trying to automatically create a user data in my firestore db when user sign up through firestore functions. However I got 2 option for sign up. Bussiness account and personal account. If user signup as bussiness then I want to add "usertype = 1" into my document and when personal then "usertype=2" I managed to automaticaly create a document on signup via functions const functions = require('firebase-functions') const admin = require('firebase-admin') admin.initializeApp() const db =

Flutter: How to update an Array within an Array in the firestore

放肆的年华 提交于 2021-02-17 06:54:32
问题 banco firestore I need to update a status field in the index array [0] where time == 8:00, I need to pass this status to == "0", only that this array is inside a matrix that here in the image can be seen as a timer. How could I update this vector at index [0] by changing the status = 1 field to = 0? To update a status outside an array and passing the values by hand I am using an example like this for testing only: Firestore.instance.collection("area").document("alergia").collection("items")

Using Firebase Firestore with mobile clients directly is secure enough? How can I avoid malicious requests and excessive requests exceeding limits?

僤鯓⒐⒋嵵緔 提交于 2021-02-17 06:52:11
问题 I have some concerns about using Firestore directly from mobile clients. I saw that with Firestore, mobile app is controls to db directly. There is only db side control is rules. However I am not yet understand how can I resolve my concerns. I worrying because with decompiling app or any other ways maybe someone can access maliciously. To resolve my concerns and improve the security I want to: Limit access per time for user. For example if some one writes or reads db 30 second ago I want to