Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

The ORM-like abstraction for couchbase ruby client

tag: 0.0.1

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 tasks
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 .yardopts
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 couchbase-model.gemspec

Couchbase Model Build Status

This library allows to declare models for couchbase gem. Here are example:

require 'couchbase/model'

class Post < Couchbase::Model
  attribute :title
  attribute :body
  attribute :draft

p = => 'hello-world',
             :title => 'Hello world',
             :draft => true)
p = Post.find('hello-world')
p.body = "Once upon the times...."
p.update(:draft => false)
Post.bucket.get('hello-world')  #=> {"title"=>"Hello world", "draft"=>false,
                                #    "body"=>"Once upon the times...."}

You can also let the library generate the unique identifier for you:

p = Post.create(:title => 'How to generate ID',
                :body => 'Open up the editor...')        #=> "74f43c3116e788d09853226603000809"

There are several algorithms available. By default it use :sequential algorithm, but you can change it to more suitable one for you:

class Post < Couchbase::Model
  attribute :title
  attribute :body
  attribute :draft

  uuid_algorithm :random

You can define connection options on per model basis:

class Post < Couchbase::Model
  attribute :title
  attribute :body
  attribute :draft

  connect :port => 80, :bucket => 'blog'
Something went wrong with that request. Please try again.