google-cloud-firestore

Firestore listener killed when app goes in background for a long time

邮差的信 提交于 2021-02-08 11:49:39
问题 In my app I'm listening for a Firestore query whenever the user signs in. After the app goes in background for some time, the listener gets cancelled and the client doesn't get notified of any new changes. How do I know if a listener has been cancelled by the SDK? What's the proper way of handling this? 回答1: On most operating system this is done automatically by the system itself, in order to preserve battery life. Whether it is possible to detect this situation, and how, depends on the OS.

Apply join like SQL to get data from multiple collections - Firestore

给你一囗甜甜゛ 提交于 2021-02-08 11:30:24
问题 I have a project database setup on Firestore. For some case I just want to pull out data from multiple collections and combine them like SQL. Also we have provision of pagination with filters applied on data. So its like applying where condition and joining multiple collections to get relevant data. Can anybody help me to get this result? 回答1: Firestore read operations get documents from a single collection, or a group of collections of the same name. It has no support for server-side join

How to delete data in ListView and also from Firebase?

徘徊边缘 提交于 2021-02-08 11:29:18
问题 I am working on an Android Application that saves the medicine Inventory in Firebase. All Inventory saved on Firebase perfectly. The Links i have visited are this this I showed all inventory in the list in the Android. Now What I want to do is delete the data item from the list by having a button again every list Item. Here is my XML code of list view <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http:

Are empty documents in Firestore deleted?

随声附和 提交于 2021-02-08 11:29:18
问题 I read in this question that empty documents will be deleted in Google Firestore. Is this still true? I have empty documents in one of my collections, they've been there for months, so I guess is not true (anymore). Can anyone enlighten me? 回答1: Nope, there is nothing in place to automatically delete empty documents, as you might have a valid reason for wanting those empty documents to exist. That said, I'd typically recommend putting a dummy field into a document that you create, even if you

How to return value from firestore database?

*爱你&永不变心* 提交于 2021-02-08 11:28:26
问题 I am having a hard time returning a value from the firestore database. I am trying to return the 'amount' from the database. When setting the variable i am able to console.log the 'amount'. (see code) But when i try to return the value at the end of the function, it does not return anything.('amount' is not defined no-undef) How can i return this value. Any help would be great. Please keep in mind that i am still quite new to this topic. import firebase from 'firebase/app'; import 'firebase

admin.auth().currentUser; returning undefined in Cloud Function

淺唱寂寞╮ 提交于 2021-02-08 11:15:57
问题 I am trying to create a function that, when a device is registered in the app, will attach this device uid to the uid of the signed-in user who registered the device (this is in another firestore collection that is automatically created when a user registers). Here is my code: exports.addDeviceToUser = functions.firestore.document('device-names/{device}').onUpdate((change, context) => { const currentUser = admin.auth().currentUser; const deviceName = context.params.device; var usersRef = db

How to avoid duplication when exporting from Google Sheets to Firebase

非 Y 不嫁゛ 提交于 2021-02-08 10:53:37
问题 I'm trying to export data from Google Sheets to a collection in Google Firestore. I'm using script editor in Google Sheets to write the code. I've successfully transferred the data to Firestore. However, if I add new data to the Google Sheet and try to export to Firestore all of the data that was already in Firestore duplicates. How can I have the code only add new data and not add everything when I export? //Create a menu item for 'Export to Firestore' function onOpen() { SpreadsheetApp

How to avoid duplication when exporting from Google Sheets to Firebase

放肆的年华 提交于 2021-02-08 10:52:39
问题 I'm trying to export data from Google Sheets to a collection in Google Firestore. I'm using script editor in Google Sheets to write the code. I've successfully transferred the data to Firestore. However, if I add new data to the Google Sheet and try to export to Firestore all of the data that was already in Firestore duplicates. How can I have the code only add new data and not add everything when I export? //Create a menu item for 'Export to Firestore' function onOpen() { SpreadsheetApp

Firestore per-field security rule

允我心安 提交于 2021-02-08 10:44:23
问题 I have studied the answer to this question (which has an extremely similar title): Per field rules in Firestore Security Rules. The solution in that case was to make a field unmodifiable, I do not think that is what I am after here. I have a posts collection with a data structure as follows. { uid: string, // this is the original poster's UID title: string, content: string, likesCount: number, likerUIDs: string[] } I would like to restrict writes to the title and content fields to users with

Adding Firestore and MultiDex Causes my Android App to Crash

一世执手 提交于 2021-02-08 10:44:22
问题 I have been trying to build a simple app with Android Studio which has a Firestore implementation. When I add the following line to my build.gradle file implementation 'com.google.firebase:firebase-firestore:21.3.0' the app does not even build and throws the following error: cannot fit request class in a single dex file I have looked this issue up and found this Stackoverflow page which reccomends adding MultiDex to app. This allows the app to build, but it crashes when I try to run it in the