google-cloud-firestore

Mothod always returns false from Firestore DB query

给你一囗甜甜゛ 提交于 2020-01-15 10:13:44
问题 I have a method that checks if a list contains a user or not. For some reason it always returns false, even though the user is in the list. The function does work, I know it does find the user, just not sure why it doesn't return anything else but false . I know it works because I have another method with this code snippet in to check if the user is in the list and remove or add them. That works so I know it is pulling the list. Method: fun checkUserChatChannel(channelId: String): Boolean {

Cloud Firestore getAll() equivalent in Flutter

不想你离开。 提交于 2020-01-15 06:32:07
问题 I have several document id's and want to run a function after all of them are gathered. Right now my code looks like this: List<Future<DocumentSnapshot>> futures = []; currentVenuesIds.forEach((currentVenueId) { Future<DocumentSnapshot> venueFuture = Firestore.instance .collection('venues') .document(currentVenueId) .get(); futures.add(venueFuture); }); futures.getAll(...) //????????? This does not exist In Cloud Firestore documentation there is a method called getAll() : https://cloud.google

Firebase (Cloud Firestore) - How to convert document to a custom object in Swift 5?

半世苍凉 提交于 2020-01-14 19:24:42
问题 I've been trying to convert the document retrieved from the Firebase's Cloud Firestore to a custom object in Swift 5. (I'm following the documentation: https://firebase.google.com/docs/firestore/query-data/get-data#custom_objects). However, Xcode shows me the error Value of type 'NSObject' has no member 'data' for the line try $0.data(as: JStoreUser.self) . I've defined the struct as Codable . Does anyone know how to resolve this? Thanks! The code: func getJStoreUserFromDB() { db = Firestore

Firestore get value of Field.increment after update without reading the document data

旧巷老猫 提交于 2020-01-14 15:11:36
问题 Is there a way to retrieve the updated value of a document field updated using firestore.FieldValue.increment without asking for the document? var countersRef = db.collection('system').doc('counters'); await countersRef.update({ nextOrderCode: firebase.firestore.FieldValue.increment(1) }); // Get the updated nextOrderCode without asking for the document data? This is not cost related, but for reliability. For example if I want to create a code that increases for each order, there is no

Firestore get value of Field.increment after update without reading the document data

人走茶凉 提交于 2020-01-14 15:08:03
问题 Is there a way to retrieve the updated value of a document field updated using firestore.FieldValue.increment without asking for the document? var countersRef = db.collection('system').doc('counters'); await countersRef.update({ nextOrderCode: firebase.firestore.FieldValue.increment(1) }); // Get the updated nextOrderCode without asking for the document data? This is not cost related, but for reliability. For example if I want to create a code that increases for each order, there is no

Firestore get value of Field.increment after update without reading the document data

ぃ、小莉子 提交于 2020-01-14 15:05:47
问题 Is there a way to retrieve the updated value of a document field updated using firestore.FieldValue.increment without asking for the document? var countersRef = db.collection('system').doc('counters'); await countersRef.update({ nextOrderCode: firebase.firestore.FieldValue.increment(1) }); // Get the updated nextOrderCode without asking for the document data? This is not cost related, but for reliability. For example if I want to create a code that increases for each order, there is no

Managing Online Presence in Cloud Firestore

丶灬走出姿态 提交于 2020-01-14 10:12:15
问题 In Firebase Realtime Database, we can easily manage User presence by keeping a reference to a node and updating it as shown below: DatabaseRef presenceRef = FirebaseDatabase.getInstance().getReference("disconnectmessage"); presenceRef.onDisconnect().setValue("I disconnected!"); If I want to do the same in Cloud Firestore, is there any way to achieve it? 回答1: You can easily use both Cloud Firestore and Realtime Database in the same project. For presence, we recommend you still use the Realtime

Firestore security rule: How to ensure uniqueness of values in document?

不想你离开。 提交于 2020-01-14 06:31:30
问题 Can the below security rule ensure uniqueness of firstName, lastName, username, and email before creating a document in profiles collection? match /profiles/{document=**} { allow create: if request.auth.uid != null && (request.resource.data.firstName is string && resource.data.firstName != request.resource.data.firstName) && (request.resource.data.lastName is string && resource.data.firstName != request.resource.data.firstName) && (request.resource.data.username is string && resource.data

Google Cloud Firestore console reading of all documents and charges

无人久伴 提交于 2020-01-13 20:46:11
问题 I am new to Firestore so I have a Profiles and Users collections. In the Cloud Firestore Console when I click on Database > Firestore > Data tab > Profiles or > Users the console is reading ALL the documents in each collection. These reads are counted in the Usage tab. So my question is if I have lets say 500K documents in the Profiles collection and clicked on Data I will be charged for reading 500K docs just to view the first 25 docs only. Just clicking on Data tab the console reads all the

Import Firestore dependencies and types to node.js

…衆ロ難τιáo~ 提交于 2020-01-13 13:46:31
问题 I'm recently updating my cloud functions to TypeScript after the talks on the FirebaseSummit of this year. All my code looks quite cool, but I'm having some problems trying to recover the types of Firestore API, such QuerySnapshot , DocumentReference ... async function getEventsMadeByUser(userId: string): Promise<FirebaseFirestore.DocumentSnapshot[]> { const eventsMadeByUserQuery = await instance.collection('PrivateUserData') .doc(userId).collection(EVENTS) .where('interactionUser', '==',