【问题标题】:Get roots field of a document firestore python获取文档firestore python的根字段
【发布时间】:2020-01-28 10:05:40
【问题描述】:
所以我有一个看起来像这样的 firestore 数据库:
collection1
collection2
collection3-----Doc1
-----Doc2----Map1 (contain multiple fields)
----Map2 (contain multiple fields)
我想要的是首先检索Map1和Map2字段名称(将其放入selectfield),然后每个地图包含的字段(当相应地图的名称为选择)
有人知道怎么做吗?感谢阅读!
TL;DR
我想检索位于文档根目录的字段名称。
【问题讨论】:
标签:
python
google-cloud-firestore
【解决方案1】:
您可以执行以下操作:
// get the collection3
const collections = firestore.collection('collection3').get()
// get all documents
const documents = shopSnapshot.docs.map(doc => doc.data());
console.log(documents);
// iterate over the documents and print to the screen the every document ID
for(var i=0; i<documents.length; i++){
console.log(documents[i].id);