angularfire2

Does AngularFire2's database.list hold a reference or actually grab data?

爱⌒轻易说出口 提交于 2019-12-02 19:34:21
问题 I'm following along the with the basic AngularFire2 docs, and the general format seems to be: const items = af.database.list('/items'); // to get a key, check the Example app below items.update('key-of-some-data', { size: newSize }); My confusion is that in the source code, it seems as though calling database.list() grabs all the data at the listed url (line 114 here) Can anyone help clarify how that works? If it does indeed grab all the data, is there a better way of getting a reference

Upgrading to AngularFire 5.0

吃可爱长大的小学妹 提交于 2019-12-02 16:13:37
问题 I'm using ionic 3 with firebase. Until now I use angularfire 4.0 and the following code gave me an observable for the data from firebase: obsToData: FirebaseObjectObservable<any>; constructor(public nav: NavController, public shared: SharedProvider, public DB: AngularFireDatabase) { this.obsToData = DB.object('/myData'); } now, according to this page FirebaseObjectObservable removed and I need to use AngularFireObject instead, how can I get the data? I did the following change: obsToData:

Handeling Error when using push(data) Angularfire2

…衆ロ難τιáo~ 提交于 2019-12-02 13:35:15
问题 How to handle Error when pushing data with angularFire2? I used the following method: todoLists: AngularFireList<TodoList>; addList(data): ThenableReference { const item: Item = { name: data.task, state: false, description: 'No description' }; const todoList: TodoList = { id: '', name: data.name, items: [item] }; this.todoLists.push(todoList).then(_ => this.presentToast('List succesfuly added')) .catch(err => _ => this.presentToast('Something wrong happened')); } The problem here is that the

Test for rejected promise with Jasmine

ⅰ亾dé卋堺 提交于 2019-12-02 12:43:56
In my Angular2 app which uses AngularFire2, I have an AuthService which tries to authenticate anonymously with Firebase. I am trying to write a test that expects AngularFireAuth 's signInAnonymously to return a rejected promise; for authState to be null and an error to be thrown. I an new to Jasmine and testing in general but I think I may need to be using asynchronous tests but I'm getting quite stuck. Here is a simplified AuthService : import { Injectable } from '@angular/core'; import { AngularFireAuth } from 'angularfire2/auth'; import * as firebase from 'firebase/app'; import { Observable

get the ID of collection document from Firestore using Angularfire2 in ionic 3 [duplicate]

断了今生、忘了曾经 提交于 2019-12-02 12:03:39
问题 This question already has answers here : How to include the document id in Firestore collection in Angular 5 (4 answers) Closed last year . I'm trying to get id of the collection to use it in the ionic page: this is my interface: export interface Item { categoryOfPost: string; imageUrl: string; nameOfPost: string; cityOfPost: string; createdDate: string; currencyOfPost: string; priceOfPost: number; typeOfPost: number; statusOfPost: string; id?: string; } private itemsCollection:

Why does this firestore query require an index?

为君一笑 提交于 2019-12-02 11:53:38
问题 I have a query with a where() method with an equality operator and then an orderBy() method and I can't figure out why it requires an index. The where method checks for a value in an object (a map) and the order by is with a number. The documentation says If you have a filter with a range comparison (<, <=, >, >=), your first ordering must be on the same field So I would have thought that an equality filter would be fine. Here is my query code this.afs.collection('posts').ref .where('tags.' +

Get Key for object created after Push (Angular and Firebase)

别来无恙 提交于 2019-12-02 08:04:40
I'm having problems understanding how to use Firebase. I wrote a function to push some data in my firebase database. I need to get the Key generated after I push the data into my db. This is my function postData(order: orderInfo) { let uid = firebase.auth().currentUser.uid; this.db.list('transactions').push({ currency: order.currency, total: order.total, rate: order.rate, uid: uid }); console.log(order.$key); this.db.list('transactionsPerUser').update(uid, order.$key); } When I push the data to transactions path, it also pushes user uid so I can link the data from my user database to

How to orderBy the closest distance from current location in AngularFire2?

强颜欢笑 提交于 2019-12-02 07:29:24
I am using AngularFire2 library to query in firebase. In my firebase, i have data collection and in them, i have many rows with latitude and longitude like below: - data - 1404033346513076_1998422263740845 - location - latitude: 23.7907795 - longitude: 90.403898 - 1404033346513076_1998422263740888 - location - latitude: 23.9907795 - longitude: 91.403898 I have the latitude and longitude of my current location and i have a helper function which can determine the distance in meters between the current location and a location from the firebase data. Suppose, the function is like below:

get the ID of collection document from Firestore using Angularfire2 in ionic 3 [duplicate]

筅森魡賤 提交于 2019-12-02 06:19:00
This question already has an answer here: How to include the document id in Firestore collection in Angular 5 4 answers I'm trying to get id of the collection to use it in the ionic page: this is my interface: export interface Item { categoryOfPost: string; imageUrl: string; nameOfPost: string; cityOfPost: string; createdDate: string; currencyOfPost: string; priceOfPost: number; typeOfPost: number; statusOfPost: string; id?: string; } private itemsCollection: AngularFirestoreCollection<Item>; items: Observable<Item[]>; and this is the content of the getPosts function this.itemsCollection =

Firebase Custom Claims doesn't propagate

一世执手 提交于 2019-12-02 05:11:58
I'm working in an Angular6 app with angularfire2. I'm setting the roles as custom claims in user creation, but it doesn't seem to propagate. When I'm creating the user I send the userid, businessid and role to a cloud function: bid > businessid urole > role req.body.uid > userid const customClaims = { roles: { [bid]: urole } } admin.auth().setCustomUserClaims(req.body.uid, customClaims) .then(result => { res .status(200) .send() }) The problem is when the call to cloud function finishes and I want to redirect the user to a route which requires the user to have the custom claim set, but it