node-firestore-backup icon indicating copy to clipboard operation
node-firestore-backup copied to clipboard

Investigate support and need of backing up disabled Documents

Open yoiang opened this issue 7 years ago • 5 comments

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?

yoiang avatar Dec 19 '17 14:12 yoiang

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' });

ropaolle avatar Dec 19 '17 15:12 ropaolle

@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.

jeremylorino avatar Feb 04 '18 05:02 jeremylorino

@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.

ropaolle avatar Feb 04 '18 08:02 ropaolle

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 avatar Feb 04 '18 18:02 jeremylorino

Firestore api supports showing missing docs in a ListRequest

jeremylorino avatar Feb 04 '18 23:02 jeremylorino