rethink-odm
Simple Object Document Mapper for RethinkDB.
Install
npm install rethink-odm
Usage
var ro = ; // Run command without waiting connection to be ready.ro; // Create the model "User".var User = ro; // Create a new User.var user = name: 'Johnny'; // Create model.user;
rethinkOdm(options) / rethinkOdm.createClient(options)
Create a new rethinkOdm client. To know avalaible options, please refer to rethinkdb documentation.
var ro = ;
Events
error
Emitted when an error occurs in the connection.
ro;
connect
Emitted when the client is connected.
ro;
close
Emmited when the connection is closed.
ro;
ro.r
Expose the rethinkdb module.
ror;
ro.run(command, [cb])
Run a command using the internal rethink odm connection. The advantage is that you don't have to wait connection to be ready.
ro;
ro.createModel(options)
Create a new model.
- tableName: Name of the table
- hooks: Hooks
var User = ro;
Hooks
It's possible to add some hooks, hook are some listeners automatically applied at initialization.
var User = ro;
Model.table()
Return the table linked to the model.
ro;
new Model([data])
Create a new instance of the model.
var user = name: 'Johnny';
model.insert([cb])
Insert the model.
var user = name: 'Johnny';user;
Events
insert
Emitted before the insert.
model;
inserted
Emitted after the insert.
model;
model.update([data], [cb])
Update the model.
var user = id: '1a487dc0-f6ec-11e3-a3ac-0800200c9a66' name: 'Johnny';user;
Events
update
Emitted before the update.
model;
updated
Emitted after the update.
model;
model.delete([cb])
Delete the model.
var user = id: '1a487dc0-f6ec-11e3-a3ac-0800200c9a66';user;
Events
delete
Emitted before the deletion.
model;
deleted
Emitted after the deletion.
model;
License
MIT