Minimal models for cassandra
Ruby Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.document
.gitignore
LICENSE
README.rdoc
Rakefile
VERSION
cassandra-model-0.2.3.gem
cassandra-model-0.2.4.gem
cassandra-model.gemspec

README.rdoc

cassandra-model

Simple model support for Cassandra (github.com/fauna/cassandra)

Currently, it supports:

  • Serialisation (String, Integer, Float, Boolean, DateTime, JSON)

  • Callbacks

  • Validations

Getting started

gem install cassandra-model

Define

require 'cassandra-model'

class User << CassandraModel::Base
  column_family :Users

  key :username
  column :full_name
  column :created, :datetime
  column :profile, :json

  write_consistency_level Cassandra::Consistency::ALL
  before_save :set_created_at

  validation do
    errors << "full name required" if full_name.blank?
  end

private

  def set_created_at
    self.created = Time.now
  end
end

CRUD

User.create(:username => 'foo', :full_name => 'foo bar')

foo = User.new(:username => 'foo', :full_name => 'foo bar')
foo.save

foo.full_name = 'foo baz'
foo.save

foo = User['foo']
foo = User.get('foo')

foo.destroy

Copyright

Copyright © 2010 Tien Le. See LICENSE for details.