Skip to content
marcnicholas edited this page Feb 3, 2014 · 6 revisions

Welcome to the node-ottoman wiki!

Basic installation

Pre-requisites

npm install couchbase

npm install node-uuid

npm install underscore

Ottoman installation

npm install ottoman

"Hello World"

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 = 'brett19@gmail.com';

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
  });
});
Clone this wiki locally