【发布时间】:2020-02-11 19:52:57
【问题描述】:
documentSnapshot 文档中有一个名为 contains(string fieldName) 的公共方法。 https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/DocumentSnapshot#public-method-summary
但是当我在我的代码中使用这个方法时,我总是得到一个错误代码,比如 TypeError: documentSnapshot.contains is not a function
我弄错了吗?有解决办法吗?
这是我正在尝试做的一个示例。
let citiesRef = db.collection('cities');
let allCities = citiesRef.get()
.then(snapshot => {
snapshot.forEach(doc => {
if(doc.contains('states'){
console.log(doc.id, '=>', doc.data());
};
});
})
.catch(err => {
console.log('Error getting documents', err);
});
【问题讨论】:
标签: javascript node.js firebase google-cloud-firestore