cassilds-model
Simple model support for Cassandra (github.com/fauna/cassandra)
Currently, it supports:
-
Keys (String, Time_UUID)
-
Serialisation (String, Integer, Float, Boolean, DateTime, JSON)
-
Callbacks
-
Validations
Getting started
gem install cassilds-model
Define
require 'cassandra-model'
class User << CassandraModel::Base
column_family :Users
key :username, :string
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.