Skip to content

A library for persisting your objects into cassandra.

License

Notifications You must be signed in to change notification settings

seannui/cassandra_object

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Provides a nice API for cassandra backed storage.  Because I'm too lazy to write docs for something so new, here is an example:

        class Customer < CassandraObject::Base
          attribute :first_name,    :type => String
          attribute :last_name,     :type => String
          attribute :date_of_birth, :type => Date
  
          validate :should_be_cool

          key :uuid
  
          index :last_name
  
          association :invoices, :unique=>false, :inverse_of=>:customer

          private
  
          def should_be_cool
            unless ["Michael", "Anika", "Evan"].include?(first_name)
              errors.add(:first_name, "must be that of a cool person")
            end
          end


        end

        class Invoice < CassandraObject::Base
          attribute :number, :type=>Integer
          attribute :total, :type=>Float
          attribute :gst_number, :type=>String
  
          index :number, :unique=>true
  
          association :customer, :unique=>true, :inverse_of=>:invoices
  
          migrate 1 do |attrs|
            attrs["total"] ||= rand(2000) / 100.0
          end
  
          migrate 2 do |attrs|
            attrs["gst_number"] = "66-666-666"
          end
  
          key do
            ActiveSupport::SecureRandom.hex(64)
          end
        end
        
FAQ
===

# How do I make this work?

Sorry, it's hard right now.  If you can't figure it out you should ask nzkoz for help on #cassandra on freenode.

You need to have a checkout of edge rails in ../rails if you want to run the tests.

# Should I use this in production?

Only if you're looking to help out with the development, there are a bunch of rough edges right now.

About

A library for persisting your objects into cassandra.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published