0.01
No commit activity in last 3 years
No release in over 3 years
Cassandra-model allows you to map ColumnFamily/SuperColumnFamily in Cassandra to Ruby objects. It was designed to be fast and simple.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

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 © 2010 Tien Le. See LICENSE for details.