Data loaders are used for setting up GPII production environment by loading authorization and/or preferences test data into CouchDB. See Data Loader issue ticket for details.
Script Location: scripts/dataLoader-prefs.js
Infusion Component: gpii.dataLoader.prefsDataLoader
Component Source Code: gpii/node_modules/dataLoader/src/prefsDataLoader.js
Preferences Data Loader reads all JSON files from the given directory. Each JSON file is loaded as a individual CouchDB document with its file name as the corresponding document id.
To start the data loading of the preferences data, run the following command in the universal directory:
node scripts/dataLoader-prefs.js
| Option | Type | Description | Default |
|---|---|---|---|
dbName |
String | Required. The name of the CouchDB database to be created for loading preferences data. If the database already exists, delete it and recreate. | preferences |
dataPath |
String | Required. The directory where all preference JSON files reside. | %universal/testData/preferences/ |
couchDbUrl |
String | Required. The URL to the CouchDB. | http://localhost:5984 |
| Event | Description | Parameters | Parameters Description |
|---|---|---|---|
onDataLoaded |
Fires when all preference data has been loaded into the CouchDB. | None | |
onDataLoadedError |
Fires when an error occurs at loading preference data. | errorMsg | The error message. |
Script Location: scripts/dataLoader-auth.js
Infusion Component: gpii.dataLoader.authDataLoader
Component Source Code: gpii/node_modules/dataLoader/src/authDataLoader.js
Authorization Data Loader reads given JSON files from the file system and load them into CouchDB as they are.
To start the data loading of the authorization data, run the following command in the universal directory:
node scripts/dataLoader-auth.js
| Option | Type | Description | Default |
|---|---|---|---|
dbName |
String | Required. The name of the CouchDB database to be created for loading authorization data. If the database already exists, delete it and recreate. | auth |
dataFile |
Array | Required. An array of JSON data files to be loaded. See the section below for an example of a JSON data file. | ["%universal/testData/security/TestOAuth2DataStore.json", "%universal/gpii/node_modules/gpii-oauth2/gpii-oauth2-datastore/dbViews/views.json"] |
couchDbUrl |
String | Required. The URL to the CouchDB. | http://localhost:5984 |
Example of A JSON Data File
[
{
"_id": "user-1",
"type": "user",
"name": "chromehc",
"defaultGpiiToken": "review3_chrome_high_contrast"
}, {
"_id": "user-2",
"type": "user",
"name": "ma1",
"defaultGpiiToken": "review3_ma1"
}
]
| Event | Description | Parameters | Parameters Description |
|---|---|---|---|
onDataLoaded |
Fires when all preference data has been loaded into the CouchDB. | None | |
onDataLoadedError |
Fires when an error occurs at loading preference data. | errorMsg | The error message. |