@@ -47,11 +47,11 @@ const options = {
4747// Initiate Firebase App
4848// appName is optional, you can omit it.
4949const appName = ' [DEFAULT]'
50- initializeFirebaseApp (serviceAccount, appName, options)
50+ const firestore = initializeFirebaseApp (serviceAccount, appName, options)
5151
5252// the appName & options are OPTIONAL
53- // you can initalize the app without them
54- // initializeFirebaseApp(serviceAccount)
53+ // you can initialize the app without them
54+ // const firestore = initializeFirebaseApp(serviceAccount)
5555```
5656
5757### Export data from firestore
@@ -74,7 +74,7 @@ const options = {
7474const { backup } = require (' firestore-export-import' )
7575
7676// Start exporting your data
77- backup (' collection-name' , options).then ((data ) =>
77+ backup (firestore, ' collection-name' , options).then ((data ) =>
7878 console .log (JSON .stringify (data))
7979)
8080```
@@ -85,7 +85,7 @@ Backup a document with sub collections
8585
8686``` javascript
8787// you can pass options as a third option - optional
88- backupFromDoc (' collection-name' , ' document-id' ).then ((data ) =>
88+ backupFromDoc (firestore, ' collection-name' , ' document-id' ).then ((data ) =>
8989 console .log (JSON .stringify (data))
9090)
9191```
@@ -103,7 +103,7 @@ The result is an object of collection's data.
103103``` javascript
104104const { backups } = require (' firestore-export-import' )
105105
106- backups ([' collectionName1' , ' collectionName2' ]) // Array of collection's name is OPTIONAL
106+ backups (firestore, [' collectionName1' , ' collectionName2' ]) // Array of collection's name is OPTIONAL
107107 .then ((collections ) => {
108108 // You can do whatever you want with collections
109109 console .log (JSON .stringify (collections))
@@ -118,7 +118,7 @@ You are can back update based on query criteria. In this example, I am backing u
118118const queryByName = (collectionRef ) =>
119119 collectionRef .where (' name' , ' ==' , ' Dale Nguyen' ).get ()
120120
121- const users = await backup (' users' , {
121+ const users = await backup (firestore, ' users' , {
122122 queryCollection: queryByName,
123123})
124124```
@@ -187,11 +187,11 @@ const serviceAccount = require('./serviceAccountKey.json')
187187// Initiate Firebase App
188188// appName is optional, you can omit it.
189189const appName = ' [DEFAULT]'
190- initializeFirebaseApp(serviceAccount, databaseURL, appName)
190+ const firestore = initializeFirebaseApp(serviceAccount, databaseURL, appName)
191191
192192// Start importing your data
193193// The array of date, location and reference fields are optional
194- restore(' your-file-path.json' , {
194+ restore(firestore, ' your-file-path.json' , {
195195 dates: [' date1' , ' date1.date2' , ' date1.date2.date3' ],
196196 geos: [' location' , ' locations' ],
197197 refs: [' refKey' , ' arrayRef' ],
@@ -204,13 +204,13 @@ restore('your-file-path.json', {
204204import request from ' request-promise' ;
205205...
206206const backupData = await request(' JSON-URL' );
207- const status = await restore(JSON.parse(backupData), {
207+ const status = await restore(firestore, JSON.parse(backupData), {
208208 dates: [' date' ],
209209 geos: [' location' ]
210210});
211211```
212212
213- The JSON is formated as below. The collection name is **test**. **first-key** and **second-key** are document ids.
213+ The JSON is formatted as below. The collection name is **test**. **first-key** and **second-key** are document ids.
214214
215215```json
216216{
0 commit comments