导出特定的Firestore子集合

导出特定的Firestore子集合

本文介绍了导出特定的Firestore子集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用beta版本的firestore导出工具在Firestore中导出/导入特定的子集合.

I am trying to export/import a specific sub-collection in Firestore using the beta version of the firestore export tool.

例如,如果我有一个设置

For example, if I have a setup of

  • 公司
  • companies/{company}/用户
  • 团队
  • 团队/{team}/用户

我想做的只是获取公司集合及其所有子集合:

I want to just get the companies collection and all of its subcollections, I was looking to do:

gcloud beta firestore export gs://my-bucket-name/fs_backups/companies --collection-ids='companies','users'

然后我会得到companiescompanies/{company}/usersteams/{company}/users.

我正在尝试所有这些组合:

I was trying all of these combos:

... -collection-ids='companies/{id}/users'
... -collection-ids='companies/./users'
... -collection-ids='companies/.*/users'
... -collection-ids='companies/*/users'
... -collection-ids='companies/**/users'
... -collection-ids='companies/__name__/users'

以及其他一些结果,但结果却是空的(但没有失败).

and some other ones as well, but was getting empty (but not failing) results.

集合ID是否有表示法以指定我要导出的子集合?

Is there a notation for the collection ids to specify the subcollection that I am looking to export?

推荐答案

我遇到了同样的问题.问题是,在您的示例中,至少两个子集合的名称为users.导出功能在选择特定的集合/子集合时会拉平"数据(即子集合将被导出到其自己的文件夹中,而不是父集合中的子文件夹).这使具有相同名称的子集合变得不明确.解决方法是唯一地命名子集合和集合(如果您打算以后将其导入到BigQuery中,这也将很有帮助).

I ran into the same problem. The issue is that at least two subcollections, in your example, have the name users. The export functionality, when selecting specific collections/subcollections, "flattens" the data (i.e. subcollections will be exported into its own folder, as opposed to a subfolder within the parent collection). This makes subcollections with the same name ambiguous. The fix is to uniquely name subcollections and collections (this will also be helpful if you plan to later import it into BigQuery).

这篇关于导出特定的Firestore子集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 13:17