orz
A simple redis data layer framework
example
var orz =// create a new schemausers = orz;// create a new recordusers;
output
$ node test.js
{ id: 123, name: 'Peter Gao', email: 'gxcsoccer@126.com' }
methods
var orz = ;
var r = orz(option={})
init orz object using following options
option:
- namespace --optional, if not set, default value will be "orz"
- redis --optional, if set, use the existing redis connection
- port --optional, the redis server port number
- host --optional, the redis server host
- password --optional, the password for redis authentication
- database --optional, the database number of redis
r.get(schema)
get exists schema by name, or create a new schema
return: a Record object
Record API
Record.all(...)
get all records in this collection
rall {// ...};
Record.count(...)
get the total count of this collection
r;
Record.get(...)
get one record or several records by id/ids
r;r;
Record.where(...)
query record(s)
// using functionr;// using objectr;
Record.update(...)
update record(s)
r;
Record.remove(...)
remove record(s)
r;
Record.clear(...)
clear all records in this collection
rclear {// ...};
tools
mysql2redis
this tool can help u to generate schema automatically. it schema will save to a .json file in './schema' folder
var mysql2redis = ;mysql2redis;