google-cloud-firestore

Combine streams from Firestore in flutter

我与影子孤独终老i 提交于 2020-01-31 03:50:26
问题 I have been trying to listen to more than one collection from Firestone using a StreamBuilder or something similar. My original code when I was working with only one Stream was: import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; class List extends StatefulWidget{ ///The reference to the collection is like ///Firestore.instance.collection("users").document(firebaseUser.uid).collection("list1").reference()

How get the first letter of displayName of a user during google sign in by using flutter and firestore?

守給你的承諾、 提交于 2020-01-30 12:27:29
问题 And How capitalize the displayName first element? How I get the capital first letter of displayName of user, who just registered on my app and store the first letter in firestore. Here is my code to store the data in firestore. void updateUserData(FirebaseUser user) async { DocumentReference ref = _db.collection('users').document(user.uid); return ref.setData({ 'uid': user.uid, 'email': user.email, 'photoURL': user.photoUrl, 'displayName': user.displayName, 'lastSeen': DateTime.now() }, merge

Every document read in a transaction must also be written : Firestore Transaction Exception in android

五迷三道 提交于 2020-01-30 11:26:25
问题 Firestore Transactions is giving me the following error : Caused by: com.google.firebase.firestore.FirebaseFirestoreException: Every document read in a transaction must also be written. Here's the piece of code: db.runTransaction(new Transaction.Function<Void>() { @Override public Void apply(Transaction transaction) throws FirebaseFirestoreException { DocumentReference docRef2 = db.collection("ABC").document(mMatchedUserId); DocumentReference ref3 = db.collection("XYZ").document

Updating a string field in all documents found in a collection in Firestore

不问归期 提交于 2020-01-30 11:17:46
问题 Basically, I would like to know if it is possible to update all of the documents found in a collection in Firestore. I am able to get all the documents in a list like so: mFirebaseFirestore.collection("Events").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { @Override public void onComplete(@NonNull Task<QuerySnapshot> task) { if (task.isSuccessful()) { List<String> list = new ArrayList<>(); for (QueryDocumentSnapshot document : task.getResult()) { list.add(document

Updating a string field in all documents found in a collection in Firestore

百般思念 提交于 2020-01-30 11:16:11
问题 Basically, I would like to know if it is possible to update all of the documents found in a collection in Firestore. I am able to get all the documents in a list like so: mFirebaseFirestore.collection("Events").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { @Override public void onComplete(@NonNull Task<QuerySnapshot> task) { if (task.isSuccessful()) { List<String> list = new ArrayList<>(); for (QueryDocumentSnapshot document : task.getResult()) { list.add(document

Flutter Firestore Query Nested Subcollections

ε祈祈猫儿з 提交于 2020-01-30 10:50:31
问题 I am trying to query subcollection in Firebase, but I always get an empty list... This is my query: Firestore.instance.collection('messages').where('idFrom', isEqualTo: userID).snapshots(); I know that I have subcollection with another subcollection here.. /messages/RWzG98s92mVTZniofez6YoYsNhA3-tT2Q16n1FMZoTNZQOejtWuJdCmD2/RWzG98s92mVTZniofez6YoYsNhA3-tT2Q16n1FMZoTNZQOejtWuJdCmD2/1579394957103 And my question is how to query these types of models? 回答1: Since Firstore queries are always

Flutter Firestore Query Nested Subcollections

无人久伴 提交于 2020-01-30 10:48:11
问题 I am trying to query subcollection in Firebase, but I always get an empty list... This is my query: Firestore.instance.collection('messages').where('idFrom', isEqualTo: userID).snapshots(); I know that I have subcollection with another subcollection here.. /messages/RWzG98s92mVTZniofez6YoYsNhA3-tT2Q16n1FMZoTNZQOejtWuJdCmD2/RWzG98s92mVTZniofez6YoYsNhA3-tT2Q16n1FMZoTNZQOejtWuJdCmD2/1579394957103 And my question is how to query these types of models? 回答1: Since Firstore queries are always

Do I read all documents again if there is a change in the Firestore database?

ぃ、小莉子 提交于 2020-01-30 10:35:12
问题 let say I try to get a list of eventID that liked by the user by using Firestore listener. I also use offline persistence. from this thread : Firestore - Using cache until online content updates I know that the listener will be fired immediately with the results from the cache and if there is a change result, I will get another snapshot with the changes. in swift, the reference to get the list is: FirestoreDocumentReference.users(uidUser: uid).reference().collection("likedEvents")

Do I read all documents again if there is a change in the Firestore database?

守給你的承諾、 提交于 2020-01-30 10:35:10
问题 let say I try to get a list of eventID that liked by the user by using Firestore listener. I also use offline persistence. from this thread : Firestore - Using cache until online content updates I know that the listener will be fired immediately with the results from the cache and if there is a change result, I will get another snapshot with the changes. in swift, the reference to get the list is: FirestoreDocumentReference.users(uidUser: uid).reference().collection("likedEvents")

update cloud firestore document without id

﹥>﹥吖頭↗ 提交于 2020-01-30 09:33:26
问题 My Cloud Firestore looks like this: users ├────random_id_1───{name, email, ...} ├────random_id_2───{name, email, ...} ... └────random_id_n───{name, email, ...} I want to update a document of users given I have an unique identifier for it that is NOT the random id of the document (suppose, for example, the name is unique and I want to use it as identifier). How can I update a document identifying it by a field of it? 回答1: Firestore can only update documents for which it knows the complete