dalenguyen / firestore-backup-restore

NPM package for backup and restore Firebase Firestore

Home Page:https://firebaseopensource.com/projects/dalenguyen/firestore-backup-restore/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Backup specific document with a subcollection in a collection

ccfiel opened this issue · comments

How can I backup specific document with a subcollection in a collection. I tried this code

const { backup, backups, initializeApp } = require('firestore-export-import')
const serviceAccount = require('./service-account.json')

initializeApp(serviceAccount)

backup('data/00Grg9QoguND4o9PiR2Eb1p23sn2sXXSS').then((data) =>
  console.log(JSON.stringify(data))
)

I got this error

Error: Value for argument "collectionPath" must point to a collection, but was "data/00Grg9QoguND4o9PiR2Eb1p23sn2sXXSS". Your path does not contain an odd number of components.

I want to have a selective backup per user Id. Any Advice how to this?

For a single node, it's better to use firestore get data method. It's much faster.

https://firebase.google.com/docs/firestore/query-data/get-data