Package Exports
- firestore-bulk-loader
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (firestore-bulk-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
firestore-bulk-loader
A simple tool to load data to Cloud Firestore.
How to Use
Basic usage:
const serviceAccount = require('./private/credentials/service-account.json');
const data = [
{ myId: "j1", name:"John", age:30 },
{ myId: "m2", name:"Mario", age:25 },
{ myId: "b3", 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.
const serviceAccount = require('./private/credentials/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);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;