Angular 爱奥尼亚+;Firestore-bollean字段检索
我需要检索文档FIRESTORE的布尔值Angular 爱奥尼亚+;Firestore-bollean字段检索,angular,typescript,firebase,ionic3,google-cloud-firestore,Angular,Typescript,Firebase,Ionic3,Google Cloud Firestore,我需要检索文档FIRESTORE的布尔值 有人知道怎么做吗?希望你能试试这个: 使用云Firestore SDK let docRef = db.collection("following").doc("your-id"); docRef.get().then((doc)=> { if (doc.exists) { console.log("Document data:", doc.data()); let myData=doc.data();
有人知道怎么做吗?希望你能试试这个: 使用
云Firestore SDK
let docRef = db.collection("following").doc("your-id");
docRef.get().then((doc)=> {
if (doc.exists) {
console.log("Document data:", doc.data());
let myData=doc.data();
let isTrue= myData.boolean-property-name;//return true or false
} else {
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});
使用AngularFire2:
注意:
阅读本文:
您的id
-您需要在此处传递您的文档
布尔属性名
-这只是一个伪名称。您需要在此处传递实际的属性名称。在您的案例中,它类似于cug…..
Firestore不支持direct。如果要继续,请使用doc.ref.get()。您好,非常感谢您的回答。。。我尝试使用指定的代码,但它返回了3个错误,打印在链接中:()我现在进行了更改,只得到1个错误:类型“AngularFirestoreDocument”上不存在Typescript错误属性“get”。您是否使用angularfire2
?是的,我正在使用angularfire2
确定。。。我会检查链接上的文档,我相信现在解决问题更容易了。。。你在发送给我的代码上帮了我很多。。。谢谢你的帮助!:)