google-cloud-firestore

Problem detaching listener from Firestore nested / sub-collection

混江龙づ霸主 提交于 2021-01-27 11:28:14
问题 My scenario is a chat app with the following setup in Firestore channels (collection) id (doc) messages (collection) {channelObj} id (doc) messages (collection) {channelObj} etc I've successfully attached a listener to the sub collection messages although I am having trouble detaching that listener, so when I switch from and to chat channels I get duplicate entries as the listeners keep stacking. Here's the script block from my vue file <script> import firestore from 'firebase/firestore'

Problem detaching listener from Firestore nested / sub-collection

爱⌒轻易说出口 提交于 2021-01-27 11:26:06
问题 My scenario is a chat app with the following setup in Firestore channels (collection) id (doc) messages (collection) {channelObj} id (doc) messages (collection) {channelObj} etc I've successfully attached a listener to the sub collection messages although I am having trouble detaching that listener, so when I switch from and to chat channels I get duplicate entries as the listeners keep stacking. Here's the script block from my vue file <script> import firestore from 'firebase/firestore'

Problem detaching listener from Firestore nested / sub-collection

拜拜、爱过 提交于 2021-01-27 11:25:35
问题 My scenario is a chat app with the following setup in Firestore channels (collection) id (doc) messages (collection) {channelObj} id (doc) messages (collection) {channelObj} etc I've successfully attached a listener to the sub collection messages although I am having trouble detaching that listener, so when I switch from and to chat channels I get duplicate entries as the listeners keep stacking. Here's the script block from my vue file <script> import firestore from 'firebase/firestore'

Firestore FieldValue increment with nested object and variable field-name not working

给你一囗甜甜゛ 提交于 2021-01-27 11:23:30
问题 I understand to use Firestore FieldValue increment function in the nested object I need to mention the completed path in the update method. My Ionic 5 project's main method takes the name of the field of the object. Following are the ways I have tried to use it updateCounter(attr: string){ Way1: let obj = {}; obj[attr] = firebase.firestore.FieldValue.increment(1); //This is working obj.count[attr] = firebase.firestore.FieldValue.increment(1); //This is not working. Value is always 1 this.afs

Is there a way to batch read firebase documents

a 夏天 提交于 2021-01-27 05:27:56
问题 I am making a mobile app using flutter with firebase as my backend. I have a collection of user document that stores user information. one of the fields is an array of references (reference documents in another collection) which I want to use in an operation like batch that in that would then allow be to read all the documents. I know batch only allows writes to the database, My second option would be Transaction, which requires writes after reads which I am trying to avoid. Is there a way to

How to make functions work with Firestore?

十年热恋 提交于 2021-01-27 05:24:36
问题 functions/index.js: const functions = require('firebase-functions') const admin = require('firebase-admin') admin.initializeApp(functions.config().firebase) const db = admin.database().ref() exports.app = functions.https.onRequest((req, res) => { // do whatever here... db.child('something').once('value').then(snap => console.log(snap.key)) }) Above works for Firebase. I'm interested in making this example work from functions. Something like this but working: const functions = require(

Firestore: Query collection using “where” and only retrieve document IDs

爷,独闯天下 提交于 2021-01-27 04:12:07
问题 I want to query a firestore documents collection and want only retrieve the document ids with angularfire2, to save costs for reading all documents . As far as I understand it, the following code is retrieving all documents too and is causing read ops on all documents, no matter if I use doc.data() or not. Am I right? db.collection("cities").where("capital", "==", true).onSnapshot(function(querySnapshot) { querySnapshot.forEach(function(doc) { console.log(doc.id); } }); So in the

Firestore: Query collection using “where” and only retrieve document IDs

泄露秘密 提交于 2021-01-27 04:11:35
问题 I want to query a firestore documents collection and want only retrieve the document ids with angularfire2, to save costs for reading all documents . As far as I understand it, the following code is retrieving all documents too and is causing read ops on all documents, no matter if I use doc.data() or not. Am I right? db.collection("cities").where("capital", "==", true).onSnapshot(function(querySnapshot) { querySnapshot.forEach(function(doc) { console.log(doc.id); } }); So in the

Which service account is used when running Firebase Cloud Functions?

只愿长相守 提交于 2021-01-26 10:29:31
问题 I'm trying to create a schedule Cloud Function exporting my Firestore database to create backups. The code is running fine when serving on my local machine (which uses my personal user account with owner role) but failes once deployed. I already found out that I need to add the 'Storage Admin' and 'Datastore Import Export Admin' to the service account used when running the cloud function, but I can't figure out which service account is used for the functions. Does anyone know which service

Value of firebase database updating to null when not not edited during update data

我的梦境 提交于 2021-01-25 03:57:32
问题 I am having a data update screen where the user can update/edit data saved in database. I have multiple fields which the user can edit. The data is prefilled with the previous value saved in database. My edit screen is as follows @override Widget build(BuildContext context) { return Scaffold( drawer: newdrawer(), appBar: newappbar( title: 'Edit Task', ), body: SingleChildScrollView( child: ConstrainedBox( constraints: BoxConstraints(), child: Center( child: Column( // mainAxisAlignment: