angularfire5

Getting a single AngularFirestoreDocument from a AngularFirestoreCollection query

岁酱吖の 提交于 2021-01-29 10:42:01
问题 In Firestore, I have a uid as a field in my Vendor documents: /vendors +doc1 uid: 1 +doc2 uid: 2 To access the vendors, I'm using the following function: getVendor(index: string): AngularFirestoreDocument<Vendor> { return afs.doc<Vendor>(`vendors/${index}`); } I'd like to create a similar function, which also returns an AngularFirestoreDocument , but the function takes a uid to get the document: getVendorByUID(uid: string): AngularFirestoreDocument<Vendor> { ... return theDoc; } It seems like

How to fetch data from firestore and inside it fetch another data (by reference)

心已入冬 提交于 2021-01-28 18:06:47
问题 I can't figure out how to fetch data from firestore when i have in data model reference (id) to another object, for example like this City {name: string; countryId: string; //primary key to another object in database } Country { name: string; } I m using AngularFire 5. After i fetch city i want fetch country and i want to asign country.name to city.countryId and i want return joined object city. I made service for this because i want fetch this data from multiple places in code. @Injectable()

AngularFire storage task observable never completes

烂漫一生 提交于 2019-12-24 07:26:52
问题 I am uploading a camera gallery image to firebase successfully, however I am unable to getDownloadURL() as the AngularFire storage task observable never completes. I have consulted the documentation following the 'Monitoring upload percentage' - Example Usage here Please can you kindly advise what I am doing wrong or recommend an alternative approach. Thanks. async onCamera(){ try{ const options: CameraOptions = { quality: 100, targetHeight:500, targetWidth:500, allowEdit: true,

Can not have access to multiple Google Firestore DB in Angular 6 application with angularfire2

可紊 提交于 2019-12-21 22:41:58
问题 I try to have access to multiple Google Firestore DB from my Angular 6 application through angularfire2 package. I initialized multiple instance of AngularFireModule in app.module.ts but couldn't find a way to have access to both DBs: @NgModule({ declarations: [ ... ], imports: [ ... AngularFireModule.initializeApp(coolStoreConfig, 'coolStore'), AngularFireModule.initializeApp(perfectStoreConfig, 'perfectStore'), ... ], ... }) Any idea? 回答1: After some searches around, the following answer

Angularfire5 - Get the key of Realtime database documents in list - #askfirebase

让人想犯罪 __ 提交于 2019-12-13 03:13:47
问题 I am loading a list and passing it to a component to then render the information. One of the items I need is the ID. How can I see that in the list. I've seen the documentation and it does not help. It only shows the key of the parent. this.allWorkouts = this.afDb.list<IWorkout>('/workouts') .valueChanges() .take(1) .map((array) => array.reverse()) as Observable<IWorkout[]>; <ion-card *ngFor="let workout of allWorkouts | async"> <card-workout [workout]="workout"></card-workout> </ion-card>

Returning $key in AngularFire 5

你离开我真会死。 提交于 2019-12-11 15:10:01
问题 I have the following code that works with AngularFire 5: export class NavigationComponent { items: Observable<any[]>; constructor(db: AngularFireDatabase) { this.items = db.list('/pages', ref => { let query = ref.limitToLast(100).orderByChild('sortOrder'); return query; }).valueChanges(); } } But now need to return item.$key which apparently is no longer returned by default in AngularFire 5. I see mention in the migration guide of needing to "map" this, but can't seem to get the right syntax

Firestore : Retrieve a single document

廉价感情. 提交于 2019-12-09 18:58:59
问题 I want to retrieve a single document from Firestore. So I do not mean the list of documents in the collection (I know how to do that). Let's say I know one of the key-value pair of the document and I would like to find and retrieve the document into Angular 4. interface Occupations { duration: number; id_entity: number; id_job: number; id_user: number; salary: number; start_time: number; } occupationDoc:AngularFirestoreDocument<Occupations>; occupation: Observable<Occupations>; <h1>A specific

How to get particular document data with id ? | AngularFire 5.1.1 | Cloud Firestore | Documents

那年仲夏 提交于 2019-12-08 00:53:10
问题 I am using Data access service to get the data from firebase firestore. How to use snapshotChanges()method for getting particular document data with id getProduct(id: number): Observable<Product> { this.productsDocuments = this.angularfirestore.doc<Product>('products/' + id); this.product = this.productsDocuments.snapshotChanges().pipe( map(changes => changes.map(a => { const data = a.payload.doc.data() as Product; const id = a.payload.doc.id; return { id, ...data }; })) ); return this

How to get particular document data with id ? | AngularFire 5.1.1 | Cloud Firestore | Documents

人盡茶涼 提交于 2019-12-06 11:44:06
I am using Data access service to get the data from firebase firestore. How to use snapshotChanges()method for getting particular document data with id getProduct(id: number): Observable<Product> { this.productsDocuments = this.angularfirestore.doc<Product>('products/' + id); this.product = this.productsDocuments.snapshotChanges().pipe( map(changes => changes.map(a => { const data = a.payload.doc.data() as Product; const id = a.payload.doc.id; return { id, ...data }; })) ); return this.product I want this.product returns the document value and document id Thank You!! Ezzabuzaid A document is

Firestore : Retrieve a single document

偶尔善良 提交于 2019-12-01 09:23:09
I want to retrieve a single document from Firestore. So I do not mean the list of documents in the collection (I know how to do that). Let's say I know one of the key-value pair of the document and I would like to find and retrieve the document into Angular 4. interface Occupations { duration: number; id_entity: number; id_job: number; id_user: number; salary: number; start_time: number; } occupationDoc:AngularFirestoreDocument<Occupations>; occupation: Observable<Occupations>; <h1>A specific post:</h1> <h3>{{ (occupation | async)?.salary }}</h3> <p>{{ (occupation | async)?.id_user }}</p> <p>{