google-cloud-firestore

How to save a document with a dynamic id into Cloud Firestore? Always changing

人盡茶涼 提交于 2020-02-03 10:18:52
问题 I am using Cloud Firestore as my database This is my form codes on my webpage that creates a new document into my Cloud Firestore collection called "esequiz". So how do I code it in such a way that it always plus 1 to the number of documents there are in the database? And also set a limit to having the amount of documents inside the database form.addEventListener('submit', (e) => { e.preventDefault(); db.collection('esequiz').add({ question: form.question.value, right: form.right.value, wrong

Upgrading to Cloud Functions v1.0 and I broke everything

好久不见. 提交于 2020-02-03 10:00:27
问题 Trying to follow the instructions on this page and I can't figure out how to simply get to the data in the DocumentSnapshot. They do not really explain updating onCreate, except to say it is the same as onDelete, and I can't get that to work. exports.mFoo = functions.firestore .document('foos/{key}') .onCreate((snap, context) => { const bar = snap.data(); // <-- DOESN'T WORK console.log(bar); // <-- DOESN'T WORK return Promise; }); I get the following error: TypeError: snap.data is not a

How can I setup Firebase Storage rules to check parameters in Firebase Database?

僤鯓⒐⒋嵵緔 提交于 2020-02-02 16:16:48
问题 I have the following data structures in Firebase Firebase Database House/(id)/Viewers/(UID)/{ startdate = “Dec 1, 2019” endData = “Dec 8, 2019” } Firebase Storage House/(id)/SensitiveImages/sensitiveImage.png I want to write a rule in Firebase storage that only allows access to the SensitiveImages folder if the users UID is inside of the list of Viewers and the current time is between the startDate and endDate. However, there is no way to access this information from inside the Firebase

Firebase + React Native - Grab each Document ID

拜拜、爱过 提交于 2020-02-02 15:56:22
问题 I have been stuck on this for ages trying to figure out how I can console log each Firebase Cloudstore document ID separately when I press onto each rendered FlatList item. I can grab a certain key / id by using onPress={() =>{console.log(this.state.posts[0].key)}} etc. But I dont know how to grab each one separately. In essence I only want the document ID of the touchableOpacity I have pressed. Not just [0] Screenshots are below of App layout so you can get an understanding and also code

How to query firestore() for graphQL resolver?

寵の児 提交于 2020-02-02 12:15:29
问题 I'm combining a GraphQL app with my existing Firebase project and am having a lot of problems getting the queries to correctly get data from the firestore(). So far I have the mutations working correctly, but when I go to query the data I can't get the firestore().get() snapshot into a form that graphQL will recognize. so far it looks like this: const {GraphQLObjectType, GraphQLString, GraphQLBoolean, GraphQLFloat, GraphQLSchema, GraphQLID, GraphQLList, GraphQLNonNull} = require("graphql");

Firestore: How to query data from a map of an array

人走茶凉 提交于 2020-02-02 05:26:50
问题 Here is the schema for test db: I want to write a query that can get all the documents where contacts have id=1 in any of the array index. I have checked array_contains operator for firestore but the thing is my array have map which then have field id. Thanks 回答1: You currently can't build a query that looks for an object field within an array. The only things you can find in an array are the entire contents of an array element, not a part of an element. With NoSQL type databases, the usual

Get all fields in a document in a list - Firestore Java

 ̄綄美尐妖づ 提交于 2020-02-01 09:05:27
问题 I am trying to get all fields from a document to a ListView . I have tried foreach loop but it is not working. dbRef.collection("Shopkeeper Own Shops").document("Shopkeeper@gmail.com") .get() .addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() { @Override public void onSuccess(DocumentSnapshot documentSnapshot) { // Get all fields to a list } }); 回答1: To add all the value of all properties within a document to a list, please use the followig lines of code: dbRef.collection(

How to get collection from firestore and set to vuex state when the app is rendered?

天大地大妈咪最大 提交于 2020-02-01 04:29:05
问题 I have a firestore collection called categories. The documents in this collection are used by every page (route) in my vue application so I figured that the most efficient way to access this data would be to have a categories state in my store.js such that each component can access the categories state when it needs to instead of getting it from firestore each time. How would I set the contents of the categories collection to my vuex state when the application is rendered? Here is my store.js

How to get collection from firestore and set to vuex state when the app is rendered?

陌路散爱 提交于 2020-02-01 04:29:04
问题 I have a firestore collection called categories. The documents in this collection are used by every page (route) in my vue application so I figured that the most efficient way to access this data would be to have a categories state in my store.js such that each component can access the categories state when it needs to instead of getting it from firestore each time. How would I set the contents of the categories collection to my vuex state when the application is rendered? Here is my store.js

Firestore unique index or unique constraint?

泪湿孤枕 提交于 2020-02-01 02:13:08
问题 Is it possible in Firestore to define an index with a unique constraint? If not, how is it possible to enforce uniqueness on a document field (without using document ID)? 回答1: Yes, this is possible using a combination of two collections, Firestore rules and batched writes. https://cloud.google.com/firestore/docs/manage-data/transactions#batched-writes The simple idea is, using a batched write, you write your document to your "data" collection and at the same write to a separate "index"