google-cloud-firestore

Getting a single AngularFirestoreDocument from a AngularFirestoreCollection query

岁酱吖の 提交于 2021-01-29 10:42:01
问题 In Firestore, I have a uid as a field in my Vendor documents: /vendors +doc1 uid: 1 +doc2 uid: 2 To access the vendors, I'm using the following function: getVendor(index: string): AngularFirestoreDocument<Vendor> { return afs.doc<Vendor>(`vendors/${index}`); } I'd like to create a similar function, which also returns an AngularFirestoreDocument , but the function takes a uid to get the document: getVendorByUID(uid: string): AngularFirestoreDocument<Vendor> { ... return theDoc; } It seems like

Firestore - How to apply 'string contains' condition on a field while querying?

巧了我就是萌 提交于 2021-01-29 10:24:40
问题 Collection - Post { "postId" : "post_124", "title" : "World population 2020" } How to write a query that returns posts having the string "World population" in the "title" field? 回答1: Firestore doesn't support this level of query. See Full-text search for a possible work-around/solution. The only expressions available are: <, <=, ==, >, >=, array-contains, in, or array-contains-any. 来源: https://stackoverflow.com/questions/58760663/firestore-how-to-apply-string-contains-condition-on-a-field

Closure with FirebaseStorage (UIImage→URL)

你。 提交于 2021-01-29 10:11:08
问题 I am creating a new registration process using Firebase Auth / Storage / Firestore. Here is the process of new registration (first authenticate with Auth, register the returned User in Firestore, save the URL if there is an image) process. static func signUp(name: String, email: String, password: String, image: UIImage?, onSuccess: @escaping () -> Void, onError: @escaping (_ errorMessage: String?) -> Void) { Auth.auth().createUser(withEmail: email, password: password, completion: { user,

Unable to use firebase.firestore.FieldValue.increment

◇◆丶佛笑我妖孽 提交于 2021-01-29 10:05:24
问题 There is a method provided by firestore to increment a numeric value. But I was not able to use the function because it is undefined. I tried updating firebase in npm, tried reinstalling firebase. I currently have the 5.10.1 version of firebase. import firebase from "../base"; ... someHandler = () => { someRef.update({ count: firebase.firestore.FieldValue.increment(1) }); } 回答1: The problem is that the FieldValue is not accessible through the app instance. So I solved my problem by importing

How to get map of firebase cloud store data in node js?

好久不见. 提交于 2021-01-29 10:04:22
问题 Actually I m making a discord bot list ,I want to show all the bots ,I m using express nodejs. My data in firebase are as shown below db.collection("bots").doc("12345").set({ prefix:"?", id:"12345", server:"5" }) db.collection("bots").doc("12346").set({ prefix:"-", id:"12346", server:"7" }); const x = require ("express"); const router = x.Router () const {db} = require("../app"); db.collection("bots"). get().then((querySnapshot) => { const x = require ("express"); const router = x.Router ()

Firebase Storage security rules and firestore

自闭症网瘾萝莉.ら 提交于 2021-01-29 10:01:25
问题 I have "groups" in Firestore. Each group has a "members" key. My goal is to write a Firebase Storage security rule to allow "write" only to members of a group: # I want something like this match /groups/{groupId} { allow read, write: if request.auth.uid in get(/database/groups/{groupId}/members); } 回答1: Security rules cannot read from another service, so you won't be able to implement groups in the way you describe here. You'll instead have to encode the knowledge of what groups somebody is a

How to complete login only after functions.auth.user().onCreate is finished

◇◆丶佛笑我妖孽 提交于 2021-01-29 09:55:42
问题 I'm using firebase functions and I have a function which add new collection when user is creating. The problem is sometimes user is logged in before function is done, so user is logged in but new collection is not created yet (and then I have error message 'Missing or insufficient permissions. because a rule cannot find that collection'). How can I handle it? Is it possible to finish login user (for example using google provider) only when all stuff from export const createCollection =

Cannot query Firestore database on multiple values

蓝咒 提交于 2021-01-29 09:31:59
问题 I have a database full with cars. The JSON format is this: docId: { "countries": ["Netherlands"] "cities": ["Amsterdam"] } I cannot query both arrays. db.collection("EU-CARS") .whereArrayContains("countries", "Netherlands") .whereArrayContains("cities", "Amsterdam"); How to solve this? 回答1: As you already noticed, Firestore allow you to filter your cars using only one whereArrayContains() method call. If you will use more than one, an error like this will occur: Caused by: java.lang

Return a sub-collection in firebase using Angular firestore

 ̄綄美尐妖づ 提交于 2021-01-29 09:26:09
问题 I have a sub-collection called saved as a nested collection to each user. User has its own fields and a collection of saved which contains two fields and an array. I can display only user fields but i don't know a proper way to access each user sub-collection. export class SavedComponent implements OnInit{ public saved: Saved[]; public currentUser: any = null; public user: User; private subscriptions: Subscription[] = []; constructor( // Adding saved service private savedService: SavedService

delete a document in firebase when you know the field value

天大地大妈咪最大 提交于 2021-01-29 09:20:01
问题 Context: In the frontend the user can enter of delete dates for availability. This is how I added a date: Firestore.instance.collection('availableDates').add({ 'availableDates':date}); But I also need to delete a document from a collection in Firestore . I don't know the document id but I know the the field value which is unique. How would I go about deleting the document if I know the field value within the document. Here is a screen shot of firestore: 回答1: You can fetch the document first