Ionic +Firestore - 布尔字段检索
Ionic +Firestore - bollean field Retrieving
我需要检索文档 FIRESTORE
的 布尔值 的值
有人知道怎么做吗?
希望你能试试这个:
使用 Cloud 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: Docs
注:
阅读这篇文章:Google Cloud Firestore integration with Ionic and AngularFire
your-id
- 您需要在此处传递您的 doc
boolean-property-name
- 这只是一个虚拟名称。您需要在此处传递您的实际 属性 名称。在你的情况下,它就像 cug.....
Firestore 不再支持直接 .get,请改用 doc.ref.get()。
我需要检索文档 FIRESTORE
的 布尔值 的值有人知道怎么做吗?
希望你能试试这个:
使用 Cloud 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: Docs
注:
阅读这篇文章:Google Cloud Firestore integration with Ionic and AngularFire
your-id
- 您需要在此处传递您的 doc
boolean-property-name
- 这只是一个虚拟名称。您需要在此处传递您的实际 属性 名称。在你的情况下,它就像 cug.....
Firestore 不再支持直接 .get,请改用 doc.ref.get()。