qui*_* 2 javascript firebase google-cloud-firestore
如何读取 firestore 中的子集合?
db.collection('users')
.doc('5mmwJba8FVMrdHGOPBYraOQzDe22')
.collection('restaurants').get().then(function(doc) {
if (doc.exists) {
console.log("Document data:", doc.data());
} else {
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});
Run Code Online (Sandbox Code Playgroud)
路径是:/users/5mmwJba8FVMrdHGOPBYraOQzDe22/restaurants/qZg6gkOvYHOPXHDJAqBF
你可以在doc('qZg6gkOvYHOPXHDJAqBF')你collection('restaurants')喜欢的后面添加:
db.collection('users').doc('5mmwJba8FVMrdHGOPBYraOQzDe22')
.collection('restaurants').doc('qZg6gkOvYHOPXHDJAqBF').get().then(function(doc) {
if (doc.exists) {
console.log("Document data:", doc.data());
} else {
console.log("No such document!");
}
}).catch(function(error) {
console.log("Error getting document:", error);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2266 次 |
| 最近记录: |