google-cloud-firestore

I keep getting a slight null error when using stream builder in flutter [closed]

ぐ巨炮叔叔 提交于 2020-05-17 08:49:21
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 days ago . I keep getting a slight null error before displaying my items. Please can I get help on the best way to use streambuilder without encountering any error? 回答1: Use ConnectionState : StreamBuilder( stream: Firestore.instance.collection('stores').document(currentUserUID).snapshots(), builder: (context,

Do firestore batch writes get re-run automatically on failure?

你。 提交于 2020-05-17 08:00:32
问题 While going through the official documentation I found out that transactions are automatically re-run a finite number of times by the SDK on failure, however in case of Batch Writes it is not explicitly mentioned. The documentation does mention that batch writes are atomic just like transactions but that does not necessarily implies that they get re-run also on failure. 回答1: Batch writes are not retried if there is a failure. The entire thing is just rolled back, and you have to figure out

How to sort firebase order to Ascending using querySnapshot in swift

十年热恋 提交于 2020-05-17 06:56:27
问题 I am new in swift and I am working with firebase. I am getting the data but not in the correct order. I want to sort it into ascending order. My code is like this func getBuzz(){ db.collection("tablename").getDocuments { (querySnapshot, err) in if let err = err { print("Error getting documents: \(err)") } else { guard let docs = querySnapshot?.documents else { return } print(docs) for document in docs { self.arrdescriptionbuzz.append(document["description"] as Any) self.arrimagebuzz.append

What is the read/write cost for Firestore docRef.Collections(ctx)?

喜你入骨 提交于 2020-05-17 06:49:06
问题 I am tracking the read/write cost of my HTTP service layer functions. Am I correct that Collection/Doc/Collection/Doc chains incur no reads? reads := 0 bucketDocRef := s.fsClient.Collection("accounts").Doc(accountID).Collection("widgets").Doc(widgetID) // no cost so far? Also, what is the cost for a call to .Collections(ctx) ... is it 1 read for each collectionRef returned from iter.GetAll() ? iter := docRef.Collections(ctx) colRefs, _ := iter.GetAll() reads += len(colRefs) Also, what is the

What is the read cost of a not found docRef.Get(ctx) in Firestore?

一个人想着一个人 提交于 2020-05-17 06:48:26
问题 What is the read cost at point A, B and C? Is it always 1 read no matter what, or are there circumstances under which no read is incurred? dsnap, err := docRef.Get(ctx) if status.Code(err) == codes.NotFound { return nil, ErrNotFound // Point A } if err != nil { return nil, err // Point B } // Point C 回答1: According to the documentation on pricing: Minimum charge for queries There is a minimum charge of one document read for each query that you perform, even if the query returns no results.

Facing issues in Chat Pagination

巧了我就是萌 提交于 2020-05-17 06:42:22
问题 I am running the code to load the chats in swift iOS chat application. The problem in chat application is at "query in else{}" in function paginateData() while running the app, the first "query in if{}" runs smoothly as expected, but in other one does not run. I am using firestore database for implementing chat. My goal is to paginate the chats in the chat room. If any more information is required, please let me know. CODE func paginateData() { fetchingMore = true var query: Query! if

Manipulate value stored in Firebase document field before applying order by

故事扮演 提交于 2020-05-17 06:08:31
问题 In my Firebase Firestore, I have a large number of documents in a collection, each of which has a field called bookTime , which stores a date in String format. The format is dd MM yyyy HH , so we can't sort it in descending order to get a meaningful list with the latest document on top. The format we need for it to work properly is yyyy MM dd HH . This is my query: mQuery = mQuery.orderBy("bookTime", Query.Direction.DESCENDING); What change should I make so I can actually get a list with the

Cloud Firestore get collection by reference from another collection

十年热恋 提交于 2020-05-17 06:06:42
问题 I have a collection called Products and another one named Category . Products document has a field idCategory , referencing category's id. I want to get all documents from Products where the category name is equals "Soda". How can I do that? 回答1: I want to get all documents from Products where the category name is equals "Soda". Because you don't have all data in a single document, you need to query your database twice. Once to get the id of the category which is "Soda" in this case and then

Firestore security rules: get() use in hasAny() list method

狂风中的少年 提交于 2020-05-16 22:39:09
问题 I was wondering if this security rule would be possible: function productForUser() { return resource.data.products.hasAny(get(/databases/$(database)/documents/Users/$(request.auth.uid)).data.products); } When I try to test it in the testing plaground on the Firebase website, it is sucessful. However, when I try to run it with Javascript, with this query, I get the read denied, with "missing or insufficient permissions": query.where("products", "array-contains", productId); I can confirm that

Angular and Firestore: FirebaseError: Missing or insufficient permissions. How add idToken while observing a specific document

一曲冷凌霜 提交于 2020-05-16 22:06:24
问题 I code the code bellow that is notified in real time manner. I mean it keeps observing and soon any collection fields are updated it is loaded in Angular page. app.component.ts import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { AngularFirestore } from '@angular/fire/firestore'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent { public transfers: Observable<any[]>; constructor(db: AngularFirestore) { this