Skip to content
This repository

HTTPS clone URL

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…

Octocat-spinner-32-eaf2f5

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
README.markdown

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
end

p = Post.new(:id => 'hello-world',
             :title => 'Hello world',
             :draft => true)
p.save
p = Post.find('hello-world')
p.body = "Once upon the times...."
p.save
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...')
p.id        #=> "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
end

You can define connection options on per model basis:

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

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