google-cloud-firestore

Duplicate collectionView cells after reloadData with Firebase query

谁都会走 提交于 2021-02-13 17:29:31
问题 I have a Firebase snapshot listener that checks for new documents, adds them to an array (the collectionView datasource) and then reloads the collectionView. However, I'm getting duplicate cells in the collectionView. I currently have 3 objects in my Firebase Firestore collection but they get duplicated for a total of 9 cells. I even added a check for the index so reloadData only happens after it reaches the end of the array. Here's the relevant code: messageListener = query

displayName return null when logged using email and password

烈酒焚心 提交于 2021-02-11 18:14:30
问题 I have two options for user login, using email and password using google sign in When I log using google sign in method its display name, but it not display name when using email and password, user.displayName is return null when using 1st option. I have use provider for authenticating, I have tried currentUser method also. I store users in firestore. This is what I am getting.This is my users collection 回答1: If a user signed up using email and password, there is an option to update

displayName return null when logged using email and password

巧了我就是萌 提交于 2021-02-11 18:11:20
问题 I have two options for user login, using email and password using google sign in When I log using google sign in method its display name, but it not display name when using email and password, user.displayName is return null when using 1st option. I have use provider for authenticating, I have tried currentUser method also. I store users in firestore. This is what I am getting.This is my users collection 回答1: If a user signed up using email and password, there is an option to update

Why is the array list ratingItemList showing as empty after insertion of several items?

心已入冬 提交于 2021-02-11 17:45:26
问题 While its in the Document Snapshot loop its adding the ratings to the ratingItemList. I know this for sure because I'm also printing the size of the list in the Log and it's increasing. But after it comes out of that loop just to be sure I check whether it is empty or not and it prints Empty List in the log. Can you guys help me out locating the error? package com.example.ratingapp; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import

Why is the array list ratingItemList showing as empty after insertion of several items?

眉间皱痕 提交于 2021-02-11 17:45:10
问题 While its in the Document Snapshot loop its adding the ratings to the ratingItemList. I know this for sure because I'm also printing the size of the list in the Log and it's increasing. But after it comes out of that loop just to be sure I check whether it is empty or not and it prints Empty List in the log. Can you guys help me out locating the error? package com.example.ratingapp; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import

Setting global variable with Cloud Firestore on Kotlin

别说谁变了你拦得住时间么 提交于 2021-02-11 17:44:47
问题 again :) I got a question about Cloud Firestore and Kotlin. I need to get data from firestore with some code like this: { val comments = mutableListOf<Comment>() val firestore = FirebaseFirestore.getInstance() firestore.collection(collection).document(documentID).collection("comments") .addSnapshotListener { querySnapshot, firebaseFirestoreException -> comments = querySnapshot?.toObjects(Comment::class.java)!! // do something with 'comments'. Works: comments is populated } // do something

How to update a single field of all documents in firestore using flutter?

北慕城南 提交于 2021-02-11 17:14:55
问题 I have a 100 user documents in database, and I have to update one field to 0 in all documents. How do we do it? 回答1: Firestore doesn't offer a SQL-like "update where" command that updates everything at once, so you will have to: Query for the documents to update Iterate each DocumentSnapshot and get its DocumentReference object using the reference property For each document, update the field with its new value 回答2: Try doing the following Query the documents to update Go through each

How to update a single field of all documents in firestore using flutter?

百般思念 提交于 2021-02-11 17:12:56
问题 I have a 100 user documents in database, and I have to update one field to 0 in all documents. How do we do it? 回答1: Firestore doesn't offer a SQL-like "update where" command that updates everything at once, so you will have to: Query for the documents to update Iterate each DocumentSnapshot and get its DocumentReference object using the reference property For each document, update the field with its new value 回答2: Try doing the following Query the documents to update Go through each

how to compare user input data with my firestore record

心已入冬 提交于 2021-02-11 15:44:00
问题 I want to compare the input data of a user, with my firestore record (data that is already stored in my Firebase. Task<QuerySnapshot> pLJava = CoRef .whereEqualTo("ProgrammingLanguages", "Java") .get() .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { @Override public void onComplete(@NonNull Task<QuerySnapshot> task) { if (task.isSuccessful()) { for (QueryDocumentSnapshot document : task.getResult()) { // document.getData(); id = document.getId(); if (id.contains("Java")) { }

I need to update a certain array entry of my Map in Firestore

烂漫一生 提交于 2021-02-11 15:40:55
问题 I want to update a product of my products array. I have an array of products in a collection products[{ - 0 productPrice: 123 - 1 productPrice: 432 }] In my code I have passed the position of the element I want to update in that array of products suspend fun updateProductPrice(position:Int,shopId: String,price: Int): Resource<Unit> { FirebaseFirestore.getInstance().collection("shops").document(shopId).update("products"[position]) //here I need to get productPrice and update its value to the