google-cloud-firestore

Firebase aggregate values over property without fetching all relevant documents

强颜欢笑 提交于 2020-01-21 18:38:32
问题 I have the following firebase structure: { "company1": { "name": "Company One", "invoices": { "invoice1": { "amount": 300, "currency": "EUR", "timestamp": 1572608088 }, "invoice2": { "amount": 460, "currency": "EUR", "timestamp": 1572608088 } } } } That is to say: I have a collection companies . There is a document for each company. Each company has a subcollection invoices . Each invoice has the properties amount , currency , timestamp . Is there an efficient way of getting the sum of all

Firebase aggregate values over property without fetching all relevant documents

我们两清 提交于 2020-01-21 18:36:34
问题 I have the following firebase structure: { "company1": { "name": "Company One", "invoices": { "invoice1": { "amount": 300, "currency": "EUR", "timestamp": 1572608088 }, "invoice2": { "amount": 460, "currency": "EUR", "timestamp": 1572608088 } } } } That is to say: I have a collection companies . There is a document for each company. Each company has a subcollection invoices . Each invoice has the properties amount , currency , timestamp . Is there an efficient way of getting the sum of all

How to get the number of Firestore documents in flutter

这一生的挚爱 提交于 2020-01-21 17:44:45
问题 I am building a flutter app and using Cloud Firestore. I want to get the number of all documents in the database. I tried Firestore.instance.collection('products').toString().length but it didn't work. 回答1: First, you have to get all the documents from that collection, then you can get the length of all the documents by document List. The below could should get the job done. Firestore.instance.collection('products').getDocuments.then((myDocuments){ print("${myDocuments.documents.length}"); })

FireStore: query the Firebase Auth table?

帅比萌擦擦* 提交于 2020-01-21 15:19:04
问题 I'm building an app using Firestore, where a group of people need to be able to access an object, and I followed the guide at https://firebase.google.com/docs/firestore/solutions/role-based-access. So, my object looks a little bit like this: { title: "A Great Story", content: "Once upon a time ...", members: { alice: "host", bob: "player", david: "player", jane: "player" } } Those keys in members are simply User UID's, so in reality they don't look quite as nice of course :) Now, this all

With firestore, is it possible to configure offline persistence to set 'off' in a specific document?

会有一股神秘感。 提交于 2020-01-21 10:17:29
问题 I need to set off the persistence in a certain document in Firestore; but all other documents should work with default configuration like this implementation. I have implemented the code; but calling firestoreSettings again causing this error in below: java.lang.IllegalStateException: FirebaseFirestore has already been started and its settings can no longer be changed. You can only call setFirestoreSettings() before calling any other methods on a FirebaseFirestore object. at com.google

Firestore select where a field is null [duplicate]

荒凉一梦 提交于 2020-01-21 10:07:39
问题 This question already has an answer here : How to query Cloud Firestore for non-existing keys of documents (1 answer) Closed 2 years ago . How can I select all docs that do not have a certain field? I have the following structure: user = { firstName: 'blabla', lastName: 'bloblo', address: { city: 'xxxx', state: 'xxx' } } I have tried comparing with null, but wasn't successful. let db = firebase.firestore(); let querySnapshot = await db .collection("users") .where("address", "==", null) .get()

Firestore select where a field is null [duplicate]

僤鯓⒐⒋嵵緔 提交于 2020-01-21 10:05:40
问题 This question already has an answer here : How to query Cloud Firestore for non-existing keys of documents (1 answer) Closed 2 years ago . How can I select all docs that do not have a certain field? I have the following structure: user = { firstName: 'blabla', lastName: 'bloblo', address: { city: 'xxxx', state: 'xxx' } } I have tried comparing with null, but wasn't successful. let db = firebase.firestore(); let querySnapshot = await db .collection("users") .where("address", "==", null) .get()

Is there a way to make the firebase realtime database presence system detect disconnect faster

主宰稳场 提交于 2020-01-21 07:35:47
问题 I am creating a flutter app, it would be essential to detect almost immediately a user goes offline from the realtime/firestore database and notify other users of the same. I have tried the recommended method of subscribing to .info/connected in the realtime DB and also update a firestore DB. FirebaseDatabase.instance .reference() .child('.info') .child('connected') .onValue .listen((data) { if (data.snapshot.value == false) { // Internet has been disconnected setState(() { state.connected =

Is there a way to make the firebase realtime database presence system detect disconnect faster

江枫思渺然 提交于 2020-01-21 07:35:30
问题 I am creating a flutter app, it would be essential to detect almost immediately a user goes offline from the realtime/firestore database and notify other users of the same. I have tried the recommended method of subscribing to .info/connected in the realtime DB and also update a firestore DB. FirebaseDatabase.instance .reference() .child('.info') .child('connected') .onValue .listen((data) { if (data.snapshot.value == false) { // Internet has been disconnected setState(() { state.connected =

How to cache Firebase data in Flutter?

可紊 提交于 2020-01-20 05:20:07
问题 In my app I build a list of objects using data from Firebase. Inside a StreamBuilder, I check if the snapshot has data. If it doesen't, I am returning a simple Text widget with "Loading...". My problem is that if I go to another page in the app, and then come back, you can see for a split second that it says 'Loading...' in the middle of the screen, and it is a bit irritating. I am pretty sure it is downloading the data from Firebase, and building the widget every time I come back to that