google-cloud-firestore

FireStore create a document if not exist

南笙酒味 提交于 2020-12-24 04:01:43
问题 I want to update a doc like this: db.collection('users').doc(user_id).update({foo:'bar'}) However, if the doc user_id does not exists, the above code will throw an error. Hence, how to tell Firestore to create the student if not exists, in other word, behave like this: db.collection('users').doc(user_id).set({foo:'bar'}) 回答1: I think you want to use this code: db.collection('users').doc(user_id).set({foo:'bar'}, {merge: true}) This will set the document with the provided data and will leave

FireStore create a document if not exist

你离开我真会死。 提交于 2020-12-24 04:01:10
问题 I want to update a doc like this: db.collection('users').doc(user_id).update({foo:'bar'}) However, if the doc user_id does not exists, the above code will throw an error. Hence, how to tell Firestore to create the student if not exists, in other word, behave like this: db.collection('users').doc(user_id).set({foo:'bar'}) 回答1: I think you want to use this code: db.collection('users').doc(user_id).set({foo:'bar'}, {merge: true}) This will set the document with the provided data and will leave

Is it possible to only accept function calls from my app in Firebase?

喜夏-厌秋 提交于 2020-12-20 23:18:17
问题 I am creating a game in Unity where the user can contribute with levels using a Level Creator system. My application is setup in a way that I just need to call the Cloud Function with the level info, and it handles duplicate entries and saves it to Firestore. All of this works perfectly. My question, basically, is: can I have my functions only accept calls from my game? (without having my users registered?). Naturally, I am using functions.https.onCall((data, context) => {}) . In the

NullInjectorError: No provider for InjectionToken angularfire2.app.options

好久不见. 提交于 2020-12-20 20:13:49
问题 I'm trying to insert the form data in cloud Firestore database. Below is my x.component.ts file in which I'm getting error at constructor where I'm writing private firestore: AngularFireStore import { Component, OnInit } from '@angular/core'; import { GroupService } from '../shared/group.service'; import { NgForm } from '@angular/forms'; // import { NullTemplateVisitor } from '@angular/compiler'; import { AngularFirestore } from '@angular/fire/firestore'; // import { AngularFireModule } from

NullInjectorError: No provider for InjectionToken angularfire2.app.options

和自甴很熟 提交于 2020-12-20 20:11:51
问题 I'm trying to insert the form data in cloud Firestore database. Below is my x.component.ts file in which I'm getting error at constructor where I'm writing private firestore: AngularFireStore import { Component, OnInit } from '@angular/core'; import { GroupService } from '../shared/group.service'; import { NgForm } from '@angular/forms'; // import { NullTemplateVisitor } from '@angular/compiler'; import { AngularFirestore } from '@angular/fire/firestore'; // import { AngularFireModule } from

nested firebase-firestore rules: owner id within parent document

隐身守侯 提交于 2020-12-16 03:50:51
问题 I can't get these rules to work: I've got a collection with projects, which all have an owner. The owner should be allowed to read/write his projects and the subcollection working_copies as well. This implementation succesfully grants reading the project, but fails ( Missing or insufficient permissions ) when reading a working_copy from the sub collection. I suspect it tries to find an owner within the sub-document. service cloud.firestore { match /databases/{database}/documents { match

nested firebase-firestore rules: owner id within parent document

放肆的年华 提交于 2020-12-16 03:50:18
问题 I can't get these rules to work: I've got a collection with projects, which all have an owner. The owner should be allowed to read/write his projects and the subcollection working_copies as well. This implementation succesfully grants reading the project, but fails ( Missing or insufficient permissions ) when reading a working_copy from the sub collection. I suspect it tries to find an owner within the sub-document. service cloud.firestore { match /databases/{database}/documents { match

Why is my Firestore Stream producing duplicate results on my forEach on the snaphot?

房东的猫 提交于 2020-12-16 02:30:57
问题 I'm trying to act on a specific document change type on my Firestore Stream. I noticed that when a doc gets added or removed, I get multiple copies when I iterate over the snapshot. I'm listening to the stream in my Stateful Widget tree but I'm not calling setState anywhere. Here is relevant code: @override Widget build(BuildContext context) { var usersOnStreamQuery = placeCollection.doc(place).collection('usersOn'); ... body: Builder(builder: (BuildContext context) { usersOnStreamQuery

Why is my Firestore Stream producing duplicate results on my forEach on the snaphot?

杀马特。学长 韩版系。学妹 提交于 2020-12-16 02:27:22
问题 I'm trying to act on a specific document change type on my Firestore Stream. I noticed that when a doc gets added or removed, I get multiple copies when I iterate over the snapshot. I'm listening to the stream in my Stateful Widget tree but I'm not calling setState anywhere. Here is relevant code: @override Widget build(BuildContext context) { var usersOnStreamQuery = placeCollection.doc(place).collection('usersOn'); ... body: Builder(builder: (BuildContext context) { usersOnStreamQuery

Why is my Firestore Stream producing duplicate results on my forEach on the snaphot?

不想你离开。 提交于 2020-12-16 02:27:02
问题 I'm trying to act on a specific document change type on my Firestore Stream. I noticed that when a doc gets added or removed, I get multiple copies when I iterate over the snapshot. I'm listening to the stream in my Stateful Widget tree but I'm not calling setState anywhere. Here is relevant code: @override Widget build(BuildContext context) { var usersOnStreamQuery = placeCollection.doc(place).collection('usersOn'); ... body: Builder(builder: (BuildContext context) { usersOnStreamQuery