Sha256: 9c68a16138c53a45dd5abc368127677916e2c8bce22b2ff85842601a0231724b

Contents?: true

Size: 1.66 KB

Versions: 18

Compression:

Stored size: 1.66 KB

Contents

= Cassandra Object
{<img src="https://secure.travis-ci.org/data-axle/cassandra_object.png?rvm=1.9.3" />}[http://travis-ci.org/data-axle/cassandra_object]
{<img src="https://codeclimate.com/github/data-axle/cassandra_object.png" />}[https://codeclimate.com/github/data-axle/cassandra_object]

Cassandra Object uses ActiveModel to mimic much of the behavior in ActiveRecord.

== Installation

Add the following to your Gemfile:

  gem 'gotime-cassandra_object'

Change the version of Cassandra accordingly. Recent versions have not been backward compatible.

== Defining Models

  class Widget < CassandraObject::Base
    string :name
    string :description
    integer :price
    array :colors, unique: true

    validates :name, presence: :true

    before_create do
      self.description = "#{name} is the best product ever"
    end
  end

== Connecting to the Server

  CassandraObject::Base.config = {
    keyspace: 'my_app_development',
    servers: '127.0.0.1:9160',
    thrift: {
      timeout: 20,
      retries: 2
    }
  }

== Creating and updating records

Cassandra Object has equivalent methods as ActiveRecord:

  widget = Widget.new
  widget.valid?
  widget = Widget.create(name: 'Acme', price: 100)
  widget.update_attribute(:price, 1200)
  widget.update_attributes(price: 1200, name: 'Acme Corporation')
  widget.attributes = {price: 300}
  widget.price_was
  widget.save
  widget.save!

== Finding records

  widget = Widget.find(uuid)
  widget = Widget.first
  widgets = Widget.all
  Widget.find_each do |widget|
    ...
  end

== Scoping

Some lightweight scoping features are available:

  Widget.where('color' => 'red')
  Widget.select(['name', 'color'])
  Widget.limit(10)

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.12.2 README.rdoc
gotime-cassandra_object-4.12.1 README.rdoc
gotime-cassandra_object-4.12.0 README.rdoc
gotime-cassandra_object-4.11.6 README.rdoc
gotime-cassandra_object-4.11.5 README.rdoc
gotime-cassandra_object-4.11.4 README.rdoc
gotime-cassandra_object-4.11.3 README.rdoc
gotime-cassandra_object-4.11.2 README.rdoc
gotime-cassandra_object-4.11.1 README.rdoc
gotime-cassandra_object-4.11.0 README.rdoc
gotime-cassandra_object-4.10.5 README.rdoc
gotime-cassandra_object-4.10.4 README.rdoc
gotime-cassandra_object-4.10.3 README.rdoc
gotime-cassandra_object-4.10.2 README.rdoc
gotime-cassandra_object-4.10.1 README.rdoc
gotime-cassandra_object-4.10.0 README.rdoc
gotime-cassandra_object-4.9.2 README.rdoc
gotime-cassandra_object-4.9.1 README.rdoc