google-cloud-firestore

How to wait promises ad push data to array in forEach loop [react]

纵然是瞬间 提交于 2021-01-28 18:36:45
问题 So i want to use this effect: useEffect(() => { return db.collection('users').orderBy('lastName').onSnapshot(snap => { const usersArray = [] snap.forEach( async doc => { const user = doc.data() if(user.manager) { await Promise.all([ db.collection('users').doc(user.manager).get(), db.collection('roles').doc(user.profile).get() ]).then(resp => { const manager = resp[0].data() const role = resp[1].data() usersArray.push({ id: doc.id, ...user, manager: `${manager.lastName} ${manager.name} $

How to wait promises ad push data to array in forEach loop [react]

六眼飞鱼酱① 提交于 2021-01-28 18:35:00
问题 So i want to use this effect: useEffect(() => { return db.collection('users').orderBy('lastName').onSnapshot(snap => { const usersArray = [] snap.forEach( async doc => { const user = doc.data() if(user.manager) { await Promise.all([ db.collection('users').doc(user.manager).get(), db.collection('roles').doc(user.profile).get() ]).then(resp => { const manager = resp[0].data() const role = resp[1].data() usersArray.push({ id: doc.id, ...user, manager: `${manager.lastName} ${manager.name} $

Is there a Flutter/Dart equivalent for the IN query on a Cloud Firestore Firebase Collection ref?

南笙酒味 提交于 2021-01-28 18:30:48
问题 I want to query a Firebase collection reference with a list of multiple document IDs within a Streambuilder, but it appears the only .where() query functions available are: Query where(String field, {dynamic isEqualTo, dynamic isLessThan, dynamic isLessThanOrEqualTo, dynamic isGreaterThan, dynamic isGreaterThanOrEqualTo, dynamic arrayContains, bool isNull}) I have tested isEqualTo and this works fine if I set a string to pass in, but I can't get this to work with a list. It appears there is

How to fetch data from firestore and inside it fetch another data (by reference)

心已入冬 提交于 2021-01-28 18:06:47
问题 I can't figure out how to fetch data from firestore when i have in data model reference (id) to another object, for example like this City {name: string; countryId: string; //primary key to another object in database } Country { name: string; } I m using AngularFire 5. After i fetch city i want fetch country and i want to asign country.name to city.countryId and i want return joined object city. I made service for this because i want fetch this data from multiple places in code. @Injectable()

Is there a way to write this database call into a function easily?

假如想象 提交于 2021-01-28 14:09:10
问题 All of the text in an application I'm working on is stored inside FireStore documents, so to retrieve it I use this bit of code db.collection("language").document("kCreateNewAccount").get() .addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() { @Override public void onSuccess(DocumentSnapshot documentSnapshot) { String viewText = lan.equals("en") ? documentSnapshot.getString("en") : documentSnapshot.getString("es"); createAccount.setText(viewText); } }); I've tried to put it into a

How to update() an array of maps-objects on Firestore in Angular or Angularfirestore?

落爺英雄遲暮 提交于 2021-01-28 13:01:02
问题 I know how to READ and WRITE a document in Firestore, But how does one update() a Value of and object in an array of Maps without removing/deleteing? Just changing one value if needed. I have a Form that includes a FormArray, that are able to edit as an when there is an update on the price list. product = { id: "product id", brand: "Brand Name", model: "This is the model of the brand" lists: [ { location: "Location 1", price: "0.00" }, { location: "Location 2", price: "0.00" } ] } Component

Firestore Rule allowing overwrite

孤者浪人 提交于 2021-01-28 11:40:50
问题 I have a users collection where each document contains a name field and and an access map. "users" :[ { "mHbVq5TUY7brlleejClKm71NBGI2": { "name": "Bob Johnson", "access": { "X0w1VaVIljR1Nc5u3Sbo" : true } } ] I would like the Firestore rules to allow creation of a new document only if it doesn't already exist and only if the person performing the action has had their email verified. For the update, only the user owning that node can perform the update, the name must be a string, and the

How to fetch the data from cloud_firestore and display it in the TextField in flutter

穿精又带淫゛_ 提交于 2021-01-28 11:34:04
问题 Padding( padding: const EdgeInsets.all(14.0), child: Container( child: TextFormField( initialValue: fullName, cursorColor: Colors.deepPurpleAccent, decoration: InputDecoration( hintText: 'Full Name', focusedBorder: InputBorder.none, focusColor: Colors.deepPurpleAccent, enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: Colors.deepPurpleAccent, ), ), ), ), ), ), String fullName; void _fetchUserData() async { try { FirebaseUser _currentUser = await FirebaseAuth.instance

Trying to load all firestore documents in Node.js

自作多情 提交于 2021-01-28 11:29:45
问题 I can request a specific document in a collection successfully. But I need to be able to query all documents, as Firestore (unlike the realtime database) doesn't support exporting. I know the following is not possible, but surely there is some way to export a whole collection? router.get('/firebase', function (req, res) { var admin = require('firebase-admin'); const firebaseConfig = require('../firebaseConfig.json'); admin.initializeApp({ credential: admin.credential.cert(firebaseConfig),

Firestore security rules, nested field

寵の児 提交于 2021-01-28 10:23:16
问题 Our database structure looks like that: trips 12345 toArea radius: 150 name: "citycenter" 54321 toArea radius: 250 name: "main street" We tried to create some rules for read from document: match /chats/{trip} { match /messages/{message} { allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea != null } } It's works fine but next rules doesn't works: allow read, write: if get(/databases/$(database)/documents/trips/$(trip)).data.toArea != null allow read, write: