【发布时间】:2019-09-30 09:25:06
【问题描述】:
当用户注册时,我正在尝试使用用户 UID 作为文档 ID。
在 service.ts 中,我有这一行:
create_NewStudent(record) {
return this.firestore.collection('users').add(record);
}
这是我的注册功能
signup() {
this.afAuth.auth
.createUserWithEmailAndPassword(this.email, this.pass)
.then( token => {
console.log(token.user.uid)
});
let record = {};
record['nom'] = this.nom;
record['prenom'] = this.prenom;
record['email'] = this.email;
record['pass'] = this.pass;
record['datenaissance'] = this.datenaissance;
record['lieunaissance'] = this.lieunaissance;
record['adresse'] = this.adresse;
record['codepostal'] = this.codepostal;
record['ville'] = this.ville;
record['tel'] = this.tel;
record['secu'] = this.secu;
record['equipe'] = this.equipe;
record['poste'] = this.poste;
this.UsersService.create_NewStudent(uid,record).then(resp => {
this.nom = "";
this.prenom = "";
this.email = "";
this.pass = "";
this.datenaissance = "";
this.lieunaissance = "";
this.adresse = "";
this.codepostal = "";
this.ville = "";
this.tel = "";
this.secu = "";
this.equipe = "";
this.poste = "";
console.log(resp);
})
.then(() => {
this.modalCtrl.dismiss();
});
}
目前,当新注册时 -> 它会生成一个 doc id,但是如何使用用户 uid 作为 doc id
感谢您的帮助
【问题讨论】:
标签: javascript ionic-framework firebase-authentication google-cloud-firestore