node-firestore-backup
node-firestore-backup copied to clipboard
Investigate support and need of backing up disabled Documents
Brought to attention by @ropaolle in #12
- Is it possible, ie does the SDK support it?
- Why do people use disabled documents?
- When they use them why do they need them backed up?
Added an example of how I created empty docs. Maybe I do something that don't make sence,
- It can be done from the Web Client, se below.
- 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 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 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.
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!
Firestore api supports showing missing docs in a ListRequest