google-cloud-firestore

Need to obtain shopping cart sum after series of getDocument price lookups

被刻印的时光 ゝ 提交于 2021-01-29 18:45:25
问题 I'm trying to get the total of a shopping cart in Firestore by executing a series of for loop calls that calculate the sum of items in the shopping cart. The shopping cart is stored in a table called carts and the view upon appearing is pulled into an in-application dictionary called cartCache, of the type [String: Int]? where the key is the UID for the item and the value is the quantity of the item. However, the price of the item is stored in another collection called items . I only want to

Firebase Cloud Function to delete user

让人想犯罪 __ 提交于 2021-01-29 18:26:11
问题 We have a cloud function in my index.js: const functions = require('firebase-functions'); const firebase_tools = require('firebase-tools'); const admin = require('firebase-admin'); admin.initializeApp(); exports.deleteUser = functions.https.onCall((request, response) => { const userId = request.params.userId; console.log('deleting user: ' + userId + ' ...'); return firebase_tools.firestore .delete('messages/' + userId, { project: process.env.GCLOUD_PROJECT, recursive: true, yes: true, token:

Firebase/Firestore - database has insecure rules?

独自空忆成欢 提交于 2021-01-29 18:20:18
问题 I have a SwiftUI application, which uses Firebase as a back end, and my rules are something like this: rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { // This rule allows anyone on the internet to view, edit, and delete // all data in your Firestore database. It is useful for getting // started, but it is configured to expire after 30 days because it // leaves your app open to attackers. At that time, all client // requests to your Firestore database

'A non-null String must be provided to a Text widget' (Flutter)

半世苍凉 提交于 2021-01-29 18:12:15
问题 I've tried to fix this with the following code but I'm afraid the error is still prevalent: The following assertion was thrown building: A non-null String must be provided to a Text widget. 'package:flutter/src/widgets/text.dart': Failed assertion: line 360 pos 10: 'data != null' child: Row( children: [ Text( (contact.data()['rating'] == null) ? "n/a" : contact.data()['rating'].toString(), style: TextStyle( fontWeight: FontWeight.bold, color: Colors.tealAccent)), Padding( padding: const

Angular FireStore: applying snapshotChanges() on collection fetches all documents in collection, consume all read operation allowed quickly

≡放荡痞女 提交于 2021-01-29 17:55:03
问题 One of my collection in Firebase's Cloud Firestore has 1500+ records. I am showing that data in a grid in my angular application. The problem is that whenever i refresh the page or as i am developing the application, so on each change/save action, it recompiles and reloads the page, which make 1500 documents read operation. I was assuming that firebase will cache the resultset automatically and snapshotChanges() will just return me the new/updated record but here i am not seeing any cache

I don't understand a completion handler and I need one in my code

让人想犯罪 __ 提交于 2021-01-29 17:44:08
问题 I capture the data from Firestore and assign to array, someone in other question told me maybe I need a completion handler but I don't understand how to work, it would be very helpful if you help me with the code and explain this concept to me. class PetsTVC: UITableViewController { var db: Firestore! let uid = Auth.auth().currentUser?.uid var petslist = [String]() var pid = "" var pets = [paw]() override func viewDidLoad() { super.viewDidLoad() self.loadPets() DispatchQueue.main.async { self

Is that possible to update Firestore document child array item only

随声附和 提交于 2021-01-29 17:39:11
问题 I need to increment or decrement filed maxQty and the data structure is added in the below images. Image with the red mark is the filed and I added another image to understand the data structure Is there any way to do that? 回答1: According to the official documentation regarding updating array elements: If your document contains an array field, you can use arrayUnion() and arrayRemove() to add and remove elements. Unfortunately, arrayUnion() does not apply to your use-case, as your

How to show progress dialog until the data loads in FirestoreRecyclerAdapter

一笑奈何 提交于 2021-01-29 17:10:50
问题 I am using FirestoreRecyclerAdapter to load the data from Firestore into RecyclerView . I would like to show progress dialog until the data loads completely. How do I do that? Thanks in advance. Here is my code so far. void loadPosts() { FirestoreRecyclerOptions<Post> options = new FirestoreRecyclerOptions.Builder<Post>() .setQuery(query, Post.class) .build(); adapter = new FirestoreRecyclerAdapter<Post, DataViewHolder>(options) { @Override protected void onBindViewHolder(@NonNull

Get document id firestore angular

筅森魡賤 提交于 2021-01-29 16:32:10
问题 I tried to create a auto document id in firestore and get the document id in angular 8 using the following code but I am getting the document Id after the completion of the execution.Can anyone help me?Thanks in advance this.db.collection("testdata2").add({ "name": "Tokyo", "country": "Japan", "Date": this.date }) .then(function(docRef){ component.docid=docRef.id; console.log("Document written with ID: ", docRef.id); }) .catch(function(error) { console.error("Error adding document: ", error);

Error while sending List data to cloud firestore using REST api in flutter

╄→гoц情女王★ 提交于 2021-01-29 16:22:39
问题 I'm not able to send List of string to cloud firestore using REST api in flutter. //###### here is my code ########## Future<bool> addVisit(Visit visit) async { //function try { var response = await http.post( //post method to send data "${VISIT_API}", headers: {"Authorization": "Bearer ${Utils.loginToken}"}, Working fine upto "Facility", but getting error while inserting "Facility: as all others are String values and Facility is of type List body: json.encode( { "fields": { "status": {