steadyequipment / node-firestore-backup

Google Firebase Firestore backup tool
190 stars 51 forks source link

Investigate support and need of backing up disabled Documents #13

Open yoiang opened 6 years ago

yoiang commented 6 years ago

Brought to attention by @ropaolle in #12

  1. Is it possible, ie does the SDK support it?
  2. Why do people use disabled documents?
  3. When they use them why do they need them backed up?
ropaolle commented 6 years ago

Added an example of how I created empty docs. Maybe I do something that don't make sence,

  1. It can be done from the Web Client, se below.
  2. Not sure you need to. However, deleting fields in the parent doc may lead to "unknown" empty docs even if you are not aware of it.

Example

export const database = firebase.firestore();

// Create an empty document with a collection (is not backup'ed)
database.collection('coll-a/doc-a/coll-b').doc().set({ item1: '1', item2: '2' });

// Creates a non-empty document with a collection (is backup'ed). However, if you delete itemX we get an empty document again.
database.collection('coll-a').doc('doc-b').set({ itemX: 'x' });
database.collection('coll-a/doc-b/coll-b').doc('doc-b').set({ item1: '1', item2: '2' });
jeremylorino commented 6 years ago

@ropaolle do you have a real-world use case?

I have a few empty collections that I must have preserved but I have yet to run into a case where an empty document arises.

ropaolle commented 6 years ago

@jeremylorino not sure I understand your question. The problem I got was that a doc with only one collection as a child was not backed up. My workaround was to move the collection to the root.

jeremylorino commented 6 years ago

Ok, I misunderstood the original question.

Re-read you last comment and I understand now. And regardless of a real world usecase these documents should still be backed up; empty/dangling or not.

Gotcha!

jeremylorino commented 6 years ago

Firestore api supports showing missing docs in a ListRequest