我正在尝试使用下面的命令在云存储位置导出google firestore数据。
gcloud firestore export gs://<bucketName>/<folderName> --collection-ids=<collectionName>我想进一步通过字段名值或日期范围来过滤集合,可以这样做吗?云函数解决方案也很受欢迎。
这是我的js解决方案。
console.log('data export bucket', bucket);
const databaseName = client.databasePath(
process.env.GCLOUD_PROJECT,
'project_name'
);
const response = await client
.exportDocuments({
name: databaseName,
outputUriPrefix: bucket,
// Leave collectionIds empty to export all collections
// or define a list of collection IDs:
// collectionIds: ['users', 'posts']
collectionIds: tables,
});
console.log('successfully exportToGCS', response);
}```发布于 2020-06-08 17:58:41
在撰写本文时,Firestore导出功能中还没有这样的可能性。这些选项出现在我的脑海中:
1)由于exports and imports are charged at the same rate as read/write operations,我建议在FS中运行查询,而不是使用导出功能。您可以使用您已经提出的常规云函数来运行这样的查询。请参阅this guide for getting multiple documents from a collection。
2)如果您确实需要Firestore/Datastore导出格式,可以选择将所有过滤后的数据复制到新的集合并从中导出,但您可能需要支付比您想要的多得多的费用。
根据您下一步想要对数据执行的操作,您可以创建一个Cloud函数,该函数将侦听更改并将过滤后的数据复制到新的集合中,然后可以从中导出。
https://stackoverflow.com/questions/62257460
复制相似问题