Skip to content

Commit 235de03

Browse files
authored
Merge pull request #154 from dalenguyen/dev
update packages & refactors implementation
2 parents 0827c67 + 91316f3 commit 235de03

9 files changed

Lines changed: 992 additions & 739 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
> - :nail_care: [Polish]
1111
1212
---
13+
## [1.4.0] - 2023-07-30
14+
15+
#### - :boom: [Breaking Change]
16+
17+
- passing firestore as a parameter (#153)
18+
19+
#### - :nail_care: [Polish]
20+
21+
- update packages
1322

1423
## [1.3.7] - 2023-04-15
1524

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ const options = {
4747
// Initiate Firebase App
4848
// appName is optional, you can omit it.
4949
const 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 = {
7474
const { 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
104104
const { 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
118118
const 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.
189189
const 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', {
204204
import request from 'request-promise';
205205
...
206206
const 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
{

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firestore-export-import",
3-
"version": "1.3.6",
3+
"version": "1.4.0",
44
"description": "NPM package for backup and restore Firebase Firestore",
55
"main": "./dist/index.js",
66
"types": "dist/index.d.ts",
@@ -34,22 +34,22 @@
3434
},
3535
"homepage": "https://github.com/dalenguyen/firestore-backup-restore#readme",
3636
"devDependencies": {
37-
"@types/chai": "^4.3.4",
37+
"@types/chai": "^4.3.5",
3838
"@types/expect": "^24.3.0",
3939
"@types/mocha": "^10.0.1",
40-
"@types/node": "^18.15.11",
40+
"@types/node": "^20.4.5",
4141
"chai": "^4.3.7",
4242
"jsmin": "^1.0.1",
4343
"minimist": "1.2.8",
4444
"mocha": "^10.2.0",
4545
"request": "^2.88.2",
4646
"request-promise": "^4.2.6",
4747
"ts-node": "^10.9.1",
48-
"typescript": "^5.0.4"
48+
"typescript": "^5.1.6"
4949
},
5050
"dependencies": {
51-
"firebase-admin": "^11.6.0",
52-
"google-gax": "^3.6.0",
51+
"firebase-admin": "^11.10.1",
52+
"google-gax": "^4.0.3",
5353
"uuid": "^9.0.0"
5454
},
5555
"resolutions": {

0 commit comments

Comments
 (0)