-
Notifications
You must be signed in to change notification settings - Fork 98
Home
marcnicholas edited this page Feb 3, 2014
·
6 revisions
Welcome to the node-ottoman wiki!
npm install couchbase
npm install node-uuid
npm install underscore
npm install ottoman
The following requires that you have a bucket in Couchbase called "test".
We associate an object called User with the database, add some data to it, persist is to Couchbase and then prove that it's there by doing a find.
var Ottoman = require('/Users/marc/Code/node-ottoman/lib/ottoman');
var couchbase = require('couchbase');
var uuid = require('node-uuid');
var User = Ottoman.model('User', {
'username': 'string',
'name': 'string',
'email': 'string'
},{
bucket: new couchbase.Connection({bucket: 'default'})
});
var test = new User();
test.username = 'brett19';
test.name = 'Brett Lawson';
test.email = '[email protected]';
Ottoman.save(test, function(err) {
if (err) throw err;
User.findById(test._id, function(err, obj) {
if (err) throw err;
console.log(obj.name);
// Brett Lawson
});
});