繁体   English   中英

GCP Firestore 导出 - 按文档中的字段过滤

[英]GCP Firestore export - filter by field in document

我目前正在努力从 Firestore 的集合中导出文档。 在我的一个收藏中,json 框架的类型基本上很少。 它们之间的区别在于每个文档末尾的“operationType”行。 我想问有没有办法只导出其中一种类型的文件? 我需要 operationType: "TRANSACTION" 的文件 如果没有这种可能性,有没有办法通过那里使用的时间戳找到某些文件?

您可以执行以下操作:(这是 Python 代码)

// get the collection
const collections = firestore.collection('collection_name').get()

// get all documents
const documents = shopSnapshot.docs.map(doc => doc.data());

console.log(documents);

// iterate over the documents and get only those documents which are operationType = Transactions
newDocumentsList = []
for(var i=0; i<documents.length; i++){
    if(documents[i].operationType = 'TRANSACTION'):
         newDocumentsList.add(docuemtns[i])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM