当我添加一个包含我自己的文档ID(不是自动生成)的文档时,文档Id节点以斜体显示,如Firestore控制台的屏幕截图所示.这背后的原因是什么?
我添加数据的代码是
const billingRef = db
.collection('billing/test/2017/months/11')
.doc();
billingRef
.set({ name: 'ABC' })
.then(_ => {
console.log('saved');
})
.catch(err => {
console.log(err);
});Run Code Online (Sandbox Code Playgroud)
上面的代码成功添加了一个节点,但是以斜体添加节点"test"和"months".
我的查询在firestore中为这些记录产生零结果,代码如下.如何查询计费下的所有节点?
db.collection("billing").get().then(function(querySnapshot) {
console.log(querySnapshot.size) // this is always 0
querySnapshot.forEach(function(doc) {
console.log(doc.id, " => ", doc.data());
});
});Run Code Online (Sandbox Code Playgroud)