I have a project and my requirement is I have to set the object name dynamically.
I am using cloud firestore as database…
here is the code :
import { HttpClient } from ‘@angular/common/http’;
import { Injectable } from ‘@angular/core’;
import { AngularFirestore } from ‘angularfire2/firestore’;
@Injectable()
export class FirestoreProvider {
constructor(public http: HttpClient,
public firestore: AngularFirestore) {
}
addCurrency(branchName, currencyName, buyingRate, sellingRate) : Promise{
const id = this.firestore.createId();
return this.firestore.doc(`Exchange/${id}`).set({
id,
branchName,
currencyName,
objectName : {
buyingRate,
sellingRate
}
});
}
}