https://github.com/marcosvidolin/firestore-bulk-loader
A simple tool to load data to Cloud Firestore.🔥
https://github.com/marcosvidolin/firestore-bulk-loader
bulk-loader cloud data database firebase firestore import load loader tools
Last synced: about 1 year ago
JSON representation
A simple tool to load data to Cloud Firestore.🔥
- Host: GitHub
- URL: https://github.com/marcosvidolin/firestore-bulk-loader
- Owner: marcosvidolin
- License: mit
- Created: 2019-10-11T19:38:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T11:57:58.000Z (over 3 years ago)
- Last Synced: 2025-05-22T14:08:25.688Z (about 1 year ago)
- Topics: bulk-loader, cloud, data, database, firebase, firestore, import, load, loader, tools
- Language: JavaScript
- Homepage:
- Size: 117 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# firestore-bulk-loader
[](https://www.codacy.com/manual/marcosvidolin/firestore-bulk-loader?utm_source=github.com&utm_medium=referral&utm_content=marcosvidolin/firestore-bulk-loader&utm_campaign=Badge_Grade) [](https://travis-ci.org/marcosvidolin/firestore-bulk-loader)
A simple tool to load data to Cloud Firestore.
## How to install
```shell
npm i firestore-bulk-loader
```
## How to Use
**Basic usage:**
```javascript
const bulkLoader = require('firestore-bulk-loader');
const serviceAccount = require('./path/to/service-account.json');
const data = require('path/to/data.json');
bulkLoader.load(data, "my-collection", serviceAccount);
```
or
```javascript
const bulkLoader = require('firestore-bulk-loader');
const serviceAccount = require('./path/to/service-account.json');
const data = [
{ name:"John", age:30 },
{ name:"Mario", age:25 },
{ name:"Bruna", age:33 }
];
bulkLoader.load(data, "my-collection", serviceAccount);
```
**To specify a custom id:**
***WARN: The document will be updated if an existing ID is used.***
```javascript
const bulkLoader = require('firestore-bulk-loader');
const serviceAccount = require('./path/to/service-account.json');
const data = [
{ myId: "j1", name:"John", age:30 },
{ myId: "m2", name:"Mario", age:25 },
{ myId: "b3", name:"Bruna", age:33 }
];
// the name of the attribute to use as ID.
var options = {
documentKeyProperty: "myId"
}
bulkLoader.load(data, "my-collection", serviceAccount, options);
```
**CSV files:**
```javascript
const bulkLoader = require('firestore-bulk-loader');
const serviceAccount = require('./path/to/service-account.json');
const data = require('./path/to/data.csv');
var options = {
csv: true
}
bulkLoader.load(data, "my-collection", serviceAccount, options);
```
## Options
| Parameter | Description | Default | Required |
|---------------------|----------------------------------------|----------|----------|
| documentKeyProperty | The name of the attribute to use as ID | | No |
| csv | specifies that the data type is CSV | false | No |
## Considerations
- If you load a collection that dons't exists in the Firestore it will be created;
- If the collections already exist in the Firestore all the data will be added to the existent collection;
- A Document will only be replaced if the given 'id' alread exists in the collection. This case only happens when used **documentKeyProperty** option;
## Contributors
[](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/firestore-bulk-loader/links/0)[](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/firestore-bulk-loader/links/1)[](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/firestore-bulk-loader/links/2)[](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/firestore-bulk-loader/links/3)[](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/firestore-bulk-loader/links/4)[](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/firestore-bulk-loader/links/5)[](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/firestore-bulk-loader/links/6)[](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/firestore-bulk-loader/links/7)