google-cloud-firestore

how to test firestore methods

痴心易碎 提交于 2021-02-07 23:38:10
问题 I have the following issue: I want to test the following methods who make use of Firestore: databaseService.ts import {Injectable} from '@angular/core'; import {AngularFirestore} from '@angular/fire/firestore'; @Injectable({ providedIn: 'root' }) export class DatabaseService { constructor(private afs: AngularFirestore) { } pushToDatabase(subject: string, key: string, object: Object): void { this.afs.collection(subject).doc(key).set(JSON.parse(JSON.stringify(object))); } async getData(subject:

Casting firestore observables to custom objects

↘锁芯ラ 提交于 2021-02-07 19:56:27
问题 I'm new to angular and firestore and trying to figure out how to cast the data received from firebase directly to models. What is the best approach here? Currently I get the data, but it looks like it's not casted into a Blimp object. When I try to call getImageUrl() on it in the view, I get the following error message. ERROR TypeError: _v.context.$implicit.getImageUrl is not a function So my question: What is the best and cleanest way to cast these observables to the correct local model? I

How to communicate firebase webapp with chrome extension to avoid double login

爷,独闯天下 提交于 2021-02-07 19:49:26
问题 I have a problem with creating a communication between the external webpage and chrome extension. I suppose I need something like this. User tries to log in with login form on "example.com" using Firebase Auth (using google/Fb/email - password providers) If User logged in successfully, then the same credentials are sending to the chrome extension The extension calls signInWithCredential with taken credentials, and try to log in again If everything is ok, then User can work with firebase dB

How to communicate firebase webapp with chrome extension to avoid double login

南楼画角 提交于 2021-02-07 19:47:29
问题 I have a problem with creating a communication between the external webpage and chrome extension. I suppose I need something like this. User tries to log in with login form on "example.com" using Firebase Auth (using google/Fb/email - password providers) If User logged in successfully, then the same credentials are sending to the chrome extension The extension calls signInWithCredential with taken credentials, and try to log in again If everything is ok, then User can work with firebase dB

Is Firestore onSnapshot update event due to local client Set?

[亡魂溺海] 提交于 2021-02-07 18:19:37
问题 Simple version: When I register to onSnapshot in Firestore, is there a way to know if I am the client that pushed the update? Detailed Version: When a webpage is opened, it registers an onSnapshot callback to a Firestore collection called notes . The collection is then downloaded and stored in a local array var notes = [] . var window.notes = [] let notesRef = refs.db.collection('notes') notesRef.onSnapshot(querySnapshot => { querySnapshot.docChanges.forEach((docChange) => { switch (docChange

Get data ordered by document Id in Firestore by Javascript?

喜欢而已 提交于 2021-02-07 14:23:23
问题 Get data ordered by document Id in Firestore by Javascript In Andorid, I can use the query go to specific documents mQuery = docRef.whereEqualTo("name", name) .whereEqualTo("valid",true) .orderBy(FieldPath.documentId()) .startAt(lastDocId) .limit(LIMIT); It works, but in Javascript, I try to copy a similar query, it didn't work. var db = firebase.firestore(); var goQuery = docRef.where("name", "==", name) .where("valid", "==", true) .orderBy(db.FieldPath.documentId()) .startAfter("id0070")

Is there any way to use FieldValue.serverTimestamp() in Firebase Firestore JS without Firebase-Admin

南楼画角 提交于 2021-02-07 13:31:01
问题 According to answer below, Firebase-Admin is required to use FieldValue.serverTimestamp(). How do I get the server timestamp in Cloud Functions for Firebase with Firestore? . But I am using only Firebase JS and Firebase Firestore JS. The application runs only in client side. However, Firebase-Admin requires a server. Is there any way to use server timestamp when doing a write operation ? 回答1: Simply use Firebase.ServerValue.TIMESTAMP within your object. Like this: ref.set({ time: Firebase

Firebase JS Error: getToken aborted due to token change

折月煮酒 提交于 2021-02-07 13:28:38
问题 I'm getting a Firebase error " Error: getToken aborted due to token change " while running Firestore transaction using the JavaScript library. The error doesn't get thrown every time and I couldn't find the pattern. I suppose I've implemented some race conditions somewhere. The user flow in my app goes like this: Register a new account & submit an additional string in the same form Log user in after registration using the same credentials After log in, take that additional string and save it

Firebase JS Error: getToken aborted due to token change

爱⌒轻易说出口 提交于 2021-02-07 13:25:40
问题 I'm getting a Firebase error " Error: getToken aborted due to token change " while running Firestore transaction using the JavaScript library. The error doesn't get thrown every time and I couldn't find the pattern. I suppose I've implemented some race conditions somewhere. The user flow in my app goes like this: Register a new account & submit an additional string in the same form Log user in after registration using the same credentials After log in, take that additional string and save it

Firebase Firestore order by not working

大憨熊 提交于 2021-02-07 12:38:10
问题 I am learning about Firebase Firestore through official documentation. I was trying following code. Notifications are added using add() method of firestore. FirebaseFirestore.getInstance().colRefNotifications() .orderBy("timestamp", Query.Direction.DESCENDING) .get() .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() { @Override public void onSuccess(QuerySnapshot documentSnapshots) { if (!documentSnapshots.isEmpty()){ listNotifications.clear(); recyclerViewNotification