0.0.1 • Published 10 years ago
dgr v0.0.1
Data Garage node tool
Nodejs tool for Data Garage usage.
Install
npm install dgr
Sample
Data
[{
"Format": "48",
"Valuie": "12.3E+3",
"B Fmt": "##0.0E+0",
"VBA Fmt": "123.5E+2",
"Fmt": "##0.0E+0",
"Macro": "12.3E+3"
}, {
"Format": "49",
"Valuie": "12345.6789",
"B Fmt": "@",
"VBA Fmt": "12345.6789",
"Fmt": "@",
"Macro": "12345.6789"
}]
Usage
Public methods
dgr_obj.all(callback)
Getting all the data from resource.
var dgr= require('..');
var dgr_obj= new dgr(<data id>)
dgr_obj.all(function(err, result) {
if(err) {
console.error(err)
} else {
dgr_obj.tableize(result);
dgr_obj.col(1, function(err, col) {
console.log(col)
})
}
})
Arguments
- callback : (function)
- error: return error message, if no error return
null
- result: return result should return a JSON
- error: return error message, if no error return
- callback : (function)
dgr_obj.custom(config, callback)
Getting customize data from resource.
var dgr= require('..');
var dgr_obj= new dgr(<data id>)
dgr_obj.custom({
limit: 10,
fields: 'Format',
skip: 2,
selector: 'B Fmt=General'
}, function(err, result) {
if(err) {
console.error(err)
} else {
dgr_obj.tableize(result);
dgr_obj.col(1, function(err, col) {
console.log(col)
})
}
})
Arguments
configure : (object)
- limit: You can limit the data set you are pulling from remote, should be a number
- fields: Select the fields you want to get, should be a string seperate by comma (for example:
Format, Valuie, ...
) - skip: You could also skip the record you don't want( for example:
skip: 2
, that means the data will start from the 3) - selector : You can also select the data using greater, lesser, or equal ( for exmaple:
B Fmt=General
)
callback : (function)
- error: return error message, if no error return
null
- result: return result should return a JSON
- error: return error message, if no error return
After you fetch data from resource
Remind : You will have to use one of custom
or all
method before you use following methods.
dgr_obj.tableize(json)
see more details in https://github.com/DataGarage/node-json-table
tableize
method can convert your json to table easily.
dgr_obj.row(0, callback)
- return:
Object
- example:
example.row(0, function(err, result) {})
{
"Format": "0",
"Valuie": "12345.6789",
"B Fmt": "General",
"VBA Fmt": "",
"Fmt": "",
"Macro": ""
}
dgr_obj.col(0, callback) or dgr_obj.col(<column_name>, callback)
- return:
Array
- example:
example.col(0, function(err, result){})
- example2:
example.col('Format', function(err, result){})
[0,1,2,3,4...]
License
MIT