Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
node-firestore-import-export-bump-dep
Advanced tools
Readme
Firestore data importing, exporting, and data clearing tool.
Export a Firestore database, including collections and documents, while keeping the structure intact.
Exports a json file with the following format:
{
"__collections__": {
"companies": {
"docA": {
"name": "Big Co",
"employee_count": 2012,
"created": {
"__datatype__": "timestamp",
"value": {
"_seconds": 12343456,
"_nanoseconds": 7890
}
},
"location": {
"__datatype__": "geopoint",
"value": {
"_latitude": -123.456789,
"_longitude": 34.5678
}
},
"AdministratorRef": {
"__datatype__": "documentReference",
"value": "path/to/the/document"
},
"__collections__": {
"employees": ...,
"products": ...
}
},
"docB": ...,
"docC": ...
},
"administrators": {
"docA": ...,
"docB": ...
}
}
}
where __collections__
holds the collections for a given document (or the root of the database).
Imports need to be from a file with the same structure (e.g. from an exported file).
Be careful! This can easily overwrite or mess up your data if you import to the wrong location.
Three types of data are serialized in the export:
They each are serialized in the following format:
{
"__datatype__": "timestamp|geopoint|documentReference",
"value": "The serialized value"
}
Install using npm.
npm install -g node-firestore-import-export
or yarn
yarn global add node-firestore-import-export
Alternatively download the source.
git clone https://github.com/jloosli/node-firestore-import-export.git
This downloaded json file contains the proper credentials needed for node-firestore-import-export to authenticate.
If using Firebase Emulators, all commands
(Export, Import, and Clear) will override the account credentials
setting if the FIRESTORE_EMULATOR_HOST
environment variable is set.
The path to the account credentials can either be passed with the -a/--accountCredentials
flag, or placed in the
GOOGLE_APPLICATION_CREDENTIALS
environment variable. For example:
export GOOGLE_APPLICATION_CREDENTIALS=path/to/my/credentials.json
firestore-export -p
-a
, --accountCredentials
<path>
- path to Google Cloud account credentials JSON file.
If missing, will look at the GOOGLE_APPLICATION_CREDENTIALS
environment variable for the path.-b
, --backupFile
<path>
- Filename to store backup. (e.g. backups/full-backup.json).
Defaults to firestore-export.json
if missing.-n
, --nodePath
<path>
- Path to database node to start (e.g. collectionA/docB/collectionC).
Backs up full database if empty or missing.-p
, --prettyPrint
- JSON backups done with pretty-printing.firestore-export --accountCredentials path/to/credentials/file.json --backupFile /backups/myDatabase.json
firestore-export --accountCredentials path/to/credentials/file.json --backupFile /backups/myDatabase.json --prettyPrint
firestore-export --accountCredentials path/to/credentials/file.json --backupFile /backups/myDatabase.json --nodePath collectionA/document1/collectionCC
-a
, --accountCredentials
<path>
- path to Google Cloud account credentials JSON file.
If missing, will look at the GOOGLE_APPLICATION_CREDENTIALS
environment variable for the path.-b
, --backupFile
<path>
- Filename with backup data. (e.g. backups/full-backup.json).-n
, --nodePath
<path>
- Path to database node to start (e.g. collectionA/docB/collectionC).-y
, --yes
- Unattended import without confirmation (like hitting "y" from the command line).firestore-import --accountCredentials path/to/credentials/file.json --backupFile /backups/myDatabase.json
firestore-import --accountCredentials path/to/credentials/file.json --backupFile /backups/myDatabase.json --nodePath collectionA/document1/collectionCC
-a
, --accountCredentials
<path>
- path to Google Cloud account credentials JSON file.
If missing, will look at the GOOGLE_APPLICATION_CREDENTIALS
environment variable for the path.-n
, --nodePath
<path>
- Path to database node to start (e.g. collectionA/docB/collectionC).-y
, --yes
- Unattended clear without confirmation (like hitting "y" from the command line). Command will wait 5
seconds so you can Ctrl-C
to stop.-w
, --noWait
- Combine this with the --yes
confirmation to not wait 5 secondsfirestore-clear --accountCredentials path/to/credentials/file.json --yes
The underlying library can be used in a node or web application for importing and exporting data in a similar fashion
import {firestoreExport} from 'node-firestore-import-export';
import * as firebase from 'firebase-admin';
firebase.initializeApp({
apiKey: "AIza....",
authDomain: "YOUR_APP.firebaseapp.com",
databaseURL: "https://YOUR_APP.firebaseio.com",
storageBucket: "YOUR_APP.appspot.com",
messagingSenderId: "123456789"
});
const collectionRef = firebase.firestore().collection('collectionA/docB/collectionC');
firestoreExport(collectionRef)
.then(data=>console.log(data));
import {firestoreImport} from 'node-firestore-import-export';
import * as firebase from 'firebase-admin';
firebase.initializeApp({
apiKey: "AIza....",
authDomain: "YOUR_APP.firebaseapp.com",
databaseURL: "https://YOUR_APP.firebaseio.com",
storageBucket: "YOUR_APP.appspot.com",
messagingSenderId: "123456789"
});
const data = {
docA: {
name: 'bob',
__collections__: {}
},
docB: {
name: 'jill',
__collections__: {}
}
};
const collectionRef = firebase.firestore().collection('collectionA/docB/collectionC');
firestoreImport(data, collectionRef)
.then(()=>console.log('Data was imported.'));
import {firestoreClear} from 'node-firestore-import-export';
import * as firebase from 'firebase-admin';
firebase.initializeApp({
apiKey: "AIza....",
authDomain: "YOUR_APP.firebaseapp.com",
databaseURL: "https://YOUR_APP.firebaseio.com",
storageBucket: "YOUR_APP.appspot.com",
messagingSenderId: "123456789"
});
const collectionRef = firebase.firestore().collection('collectionA/docB/collectionC');
firestoreClear(collectionRef)
.then(()=>console.log('Everything under collectionA/docB/collectionC was removed.'));
Feel free to report bugs and make feature requests in the Issue Tracker, fork and create pull requests!
The command line was inspired heavily by SteadyEquipment's node-firestore-backup
Hey dude! Help me out for a couple of :beers:!
FAQs
Firestore data import and export
The npm package node-firestore-import-export-bump-dep receives a total of 0 weekly downloads. As such, node-firestore-import-export-bump-dep popularity was classified as not popular.
We found that node-firestore-import-export-bump-dep demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.