Access
// do this in your bootstrap file (index.js) before invoking gracenode.setup(). gracenode.use('gracenode', 'gracenode'); // once gracenode.setup is finished. you can access the module as following: gracenode.staticdata
Configurations
// staticdata module supports CSV and JSON format
{
"modules": {
"staticdata": {
"path": "directory path to the static files",
"delimiter": optional and defaults to ',', // for parsing CSV files
"quote": optional and defaults to '"' // for parsing CSV files
"index": { // optional // for getOneByIndex and getManyByIndex
"staticFileName": ["indexName", [...]]
}
}
}
}
#####API: create
StaticData create(String dataName)
Returns and instance of StaticData class
Example:
/*
In order to create a static data object from a static data file called "example.csv",
do the following:
*/
var example = gracenode.staticdata.create('example');
getOneByIndex
mixed getOneByIndex(String indexName, String indexKey, Function callback)
getManyByIndex
mixed getManyByIndex(String indexName, Array indexKeyList, Function callback)
getOne
mixed getOne(mixed key, Function callback)
getMany
mixed getMany(Array keyList, Function callback)
getAll
mixed getAll(Function calback)