A sample admin NodeJS script that reads a JSON file and save its data to Juno.
Make sure you have node.js LTS installed.
git clone https://github.com/junobuild/examples
cd examples/node/admin/save
npm ci
Note: unless you modify the IDs in the
example.json
data or the configuration, running the script out-of-the-box is going to fail because it will try to overwrite data that your controller don't own
npm run start
If you wish to use this script to upload your own data, see .env for configuration options.
Environment options are the following:
DATA_SRC
: a path to a JSON data. it should contain an array of objectDATA_KEY_FIELD
: the field within an object of the JSON data used as key - i.e. the unique keys that will be use to set the documents in teh datastoreJUNO_SATELLITE_ID
: the satellite ID to which you want to set the dataJUNO_DATASTORE_COLLECTION
: the datastore's collection in which the data should be persisted