I’m in a firebase ionic project, and I’m facing some problems. I’m newbie in mobile development, so my problem is when getting a return of a update command in firebase. In my provider I have:
private clientCollection: AngularFirestoreCollection<Client>;
constructor(
public db: AngularFirestore
) {
this.clientCollection = db.collection<Client>('clients');
this.historicoCollection = db.collection<Historico>('historico');
}
And my function after, receive a Client Object and a key of firebase register:
updateUser(user: any, key: string){
return this.clientCollection.doc<Client>(key).update(user)
}
My scan function, calls updateUser in provider:
saveUser(data: Client){
this.meuLoader.dismiss();
this.db.getUserPassword(data.password).subscribe((res) => {
if(res.length){
data.key = res[0].key;
//this.goToResult(data);
}
});
this.db.updateUser(data, data.key).then((res) => {
this.goToResult(data);
}).catch((error) => {
this.alertCtrl.create({
title: 'retorno',
subTitle: 'Erro no retorno da promisse',
buttons: ['Dismiss']
}).present();
})
}
The saveUser function calls two functions in provider. Is there a problem making this way? When I run on my device, nothing works. The node does not update…
Thanks