google-cloud-firestore

Store 2d Array in Firestore?

徘徊边缘 提交于 2020-01-25 07:18:43
问题 What's the best practice to save/return a 2d array in Firestore? Instead of creating a new collection for each array, is there a more efficient say of keeping the data structure together? Thanks! struct appleCounter { var tree = [branches] } var branches = [Int]() let treeFullOfApples = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]] let morningCount = appleCounter{ tree: treeFullOfApples } 回答1: The structure should be fairly straightforward arrays //collection array

Cloud Firestore rules proper syntax

二次信任 提交于 2020-01-25 07:05:46
问题 I need to write rules for Cloud Firestore. I want my rules to allow the creation of a new document in a collection: newDoc(field1="value-1", field2="value-2", field3="other-miscellaneous-values") only if no other document already exists in the collection with: (field1 == "value-1") and (field2 == "value-2") Though this is not very complicated, it seems still too complex to be found as an example in any tutorial that I found searching the net. Beside, the user should be free to list and read

About random result for query in Firestore

限于喜欢 提交于 2020-01-25 02:59:05
问题 I have a database in Firestore and RecycleView to put the data from it. I send some query to Firestore and it get me the result depending on my request. But what, if I want to take 3 random results from the set issued to me on request. That is I get, for example, 20 results and want to take only 3 result each time when I send a request. And each time, it must be random 3 results from this 20? I found there only one solution of the same problem: FirebaseFirestore rootRef = FirebaseFirestore

Possible to do a If Else or a Switch Statement Firestore Rules

ぃ、小莉子 提交于 2020-01-25 00:13:19
问题 Is it possible to do a Switch Statement or an if else in firestore rules? I have tried to search for it with no luck of finding an answer. What i tried was function getTier() { return get(/users/$(request.auth.uid)).data.userTier; } function canAddProduct() { if getTier() == 'UserTier.FREE' // Do additional code return doSomethingBasedOnFreeTier(); else if getTier() == 'UserTier.SILVER' // Do additional code return doSomethingBasedOnSilverTier() else if getTier() == 'UserTier.GOLD' // Do

How to query to Firestore sub document

天涯浪子 提交于 2020-01-25 00:11:06
问题 I'm working on an app and I would like to query Firestore sub document. Let me explain further. I have a collection of documents where cars are stored, each document has a particular car with description. In each of those documents above, I av a sub collection called user_data which have it's own document where a particular userid of the user who add the car to his wishlist is stored. Now I want to get the document of cars if a userid is present in its sub collection. In short, I want to get

How to query to Firestore sub document

空扰寡人 提交于 2020-01-25 00:10:34
问题 I'm working on an app and I would like to query Firestore sub document. Let me explain further. I have a collection of documents where cars are stored, each document has a particular car with description. In each of those documents above, I av a sub collection called user_data which have it's own document where a particular userid of the user who add the car to his wishlist is stored. Now I want to get the document of cars if a userid is present in its sub collection. In short, I want to get

How to get a document from a collection based on a particular field in that document

别等时光非礼了梦想. 提交于 2020-01-24 21:36:28
问题 const docRef = firestore.collection("orders").document("") I need to get the document "147OiRKFYKA3WAo5d5mk" if the field value is Admno:"11.11.1111" here is my database Thankyou for the help. 回答1: This case is mentioned in the official Firestore documentation: db.collection("orders").where("Admno", "==", "11.11.1111") .get() .then(function(querySnapshot) { querySnapshot.forEach(function(doc) { console.log(doc.id, " => ", doc.data()); //here's your doc }); }) .catch(function(error) { console

Firestore storage size limit how to store large arrays

假装没事ソ 提交于 2020-01-24 20:50:51
问题 I got a collection users/$userID/followers this user ID is the firebase UID so is 29 bytes long ( String sizes are calculated as the number of UTF-8 encoded bytes + 1.) Inside each user document i got a array named followers and another named following. Both arrays contain a lot of userID's so here's the problem. In firestore each document has a max size of 1mb so it's easy to see I'm gonna run out of space soon. My question is what's the best way to manage large arrays like this ones. Most

Firestore app works in debug but signed apk gives error

拟墨画扇 提交于 2020-01-24 20:42:47
问题 I have created complete app with firestore everythings works fine in debug apk but when i create signed apk for publishing it gives me strange error. While login with signed apk it gives blue lines of W/Firestore: (0.6.6-dev) [aei]: No setter/field for updated_at found on class com.binrafiq.reborn.mvp.data.db.model.j W/Firestore: (0.6.6-dev) [aei]: No setter/field for token found on class com.binrafiq.reborn.mvp.data.db.model.j W/Firestore: (0.6.6-dev) [aei]: No setter/field for image found

How to transform the data received from cloud_firestore into a Map

谁说我不能喝 提交于 2020-01-24 19:26:02
问题 The data from the cloud_firestore database is in the form of JSON. However, how to transform the data from JSON in a List of Map? The dummy data in my firestore 回答1: Data to List of Map: final CollectionReference ref = Firestore.instance.collection('food'); List<Map<String, dynamic>> listOfMaps = []; await ref.getDocuments().then((QuerySnapshot snapshot) { listOfMaps = snapshot.documents.map((DocumentSnapshot documentSnapshot) { return documentSnapshot.data; }).toList(); }); print(listOfMaps)