首页 > 解决方案 > 如何过滤字段值并将数据发送到 Firestore 集合?

问题描述

在名为“医生”的 Firestore 集合中,有不同的字段,包括字段“角色”。我想将医生添加到具有名为医生的角色的 Firestore 中。我怎样才能做到这一点?以下是成功将数据添加到数据库中的代码。如果可以,请告诉我添加具有特定字段名称的数据的方法。提前致谢。

服务.ts

create_Newdoctor(Record){
  return this.firestore.collection('doctors').add(Record);
}

组件.ts


CreateRecord(docForm: NgForm){
  let Record = {};
  Record['fullName']=this.fullName;
  Record['email']=this.email;

  this.DoctorService.create_Newdoctor(Record).then(res=> {
    this.fullName="";
    this.email="";
    console.log(res);
        this.message = "Added";
  }).catch(error=>{
    console.log(error);
  });
}

标签: firebasegoogle-cloud-firestoreangular9

解决方案



推荐阅读