Sha256: 53d6973d17d128847f1e3d382772fd75107647bd3b6686d4b531d28b1f1f055c

Contents?: true

Size: 1.33 KB

Versions: 35

Compression:

Stored size: 1.33 KB

Contents

== Cassandra Object

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

== Installation

Add the following to your Gemfile:

  gem 'cassandra', require: '0.8'
  gem 'gotime-cassandra_object'

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

== Defining Models

  class Widget < CassandraObject::Base
    key :uuid
    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.establish_connection(
    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

CQL is currently not supported

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
gotime-cassandra_object-2.11.0 README.rdoc
gotime-cassandra_object-2.10.11 README.rdoc
gotime-cassandra_object-2.10.10 README.rdoc
gotime-cassandra_object-2.10.9 README.rdoc
gotime-cassandra_object-2.10.8 README.rdoc
gotime-cassandra_object-2.10.7 README.rdoc
gotime-cassandra_object-2.10.6 README.rdoc
gotime-cassandra_object-2.10.5 README.rdoc
gotime-cassandra_object-2.10.4 README.rdoc
gotime-cassandra_object-2.10.3 README.rdoc
gotime-cassandra_object-2.10.2 README.rdoc
gotime-cassandra_object-2.10.1 README.rdoc
gotime-cassandra_object-2.10.0 README.rdoc
gotime-cassandra_object-2.9.2 README.rdoc
gotime-cassandra_object-2.9.1 README.rdoc
gotime-cassandra_object-2.9.0 README.rdoc
gotime-cassandra_object-2.8.6 README.rdoc
gotime-cassandra_object-2.8.5 README.rdoc
gotime-cassandra_object-2.8.4 README.rdoc
gotime-cassandra_object-2.8.3 README.rdoc