【问题标题】:GCP Firestore export - filter by field in documentGCP Firestore 导出 - 按文档中的字段过滤
【发布时间】:2020-01-24 13:55:12
【问题描述】:

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

【问题讨论】:

标签: google-cloud-platform google-cloud-firestore


【解决方案1】:

您可以执行以下操作:(这是一个 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])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-27
    • 2014-11-17
    • 1970-01-01
    • 2020-05-03
    • 1970-01-01
    • 2019-11-03
    • 1970-01-01
    相关资源
    最近更新 更多