Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly exporting "unreachable" sub-collections stopped working #73

Closed
m417z opened this issue Jun 9, 2019 · 2 comments · Fixed by #79
Closed

Directly exporting "unreachable" sub-collections stopped working #73

m417z opened this issue Jun 9, 2019 · 2 comments · Fixed by #79

Comments

@m417z
Copy link
Contributor

m417z commented Jun 9, 2019

The issue is relevant to my previous issue here: #42

I previously reported that if I have a user whose document doesn't exist, but there is a sub-collection with documents, the sub-collection of this user is not exported.

You said that it wasn't possible to fix, so I wrote a script to do manual export per "unreachable" sub-collection, similar to:

const collectionRef = admin.firestore().collection('users/' + userId + '/semesters');
firestoreImportExport.firestoreExport(collectionRef).then(/*...*/);

It worked at least until a month ago. But today I discovered that it stopped working. And it seems that it stopped working only for such "unreachable" sub-collections, i.e. sub-collections that neither get exported via the full database export.

I understand that it's a regression on the Firestore end, but perhaps you have a workaround for this. If not, it would be great if you could send the Firestore team a report about this, or alternatively point me to the regressed API call and I'll try to contact them.

As of now, I don't have a way to do a full backup of my project's database, which kinda sucks :(

@jloosli
Copy link
Owner

jloosli commented Jun 11, 2019

My suggestion would be to backup the data before deleting the parent. This is a bug/loophole that the Firebase team is actively working to close, so I wouldn't rely on an undocumented process that is likely to go away completely sooner rather than later.

@jloosli jloosli closed this as completed Jun 11, 2019
@m417z
Copy link
Contributor Author

m417z commented Jun 13, 2019

backup the data before deleting the parent

I'm not deleting the parent. I've never had it in the first place, I've created the sub-collections right away without ever having the parent document.

undocumented process

What are you referring to as an undocumented process? I don't think that my system does anything undocumented.

In any case, I tried other export tools in the hope to find one that works, and found out that:

  • Non of the three or so available tools support exporting sub-collections correctly.
  • There are a number of reported issues for these projects related to sub-collections, meaning that there are users who need this feature.

Fortunately, I found this pull request of @kitfit-dave who came up with a way to export sub-collections correctly:
willhlaw/node-firestore-backup-restore#55

I've incorporated a similar change to your project and it fixes the issue. I'll create a pull request soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants