Cequel is a full-featured Cassandra ORM for Ruby.

Install it.

source 'https://rubygems.org'

gem 'rails'
gem 'cequel'

Create a model.

class User
  include Cequel::Record

  key :id, :uuid, auto: true
  column :email, :ascii
  column :encrypted_password, :ascii

  validates :email, :encrypted_password, presence: true
end

Migrate automatically.

$ rake cequel:migrate
Synchronized schema for User
$ 

Declare relationships.

class User
  include Cequel::Record

  key :id, :uuid, auto: true
  column :email, :ascii
  column :encrypted_password, :ascii

  has_many :messages

  validates :email, :encrypted_password, presence: true
end

Declare relationships.

class Message
  belongs_to :user
  key :id, :timeuuid, auto: true, order: :desc
  column :sender_id, :uuid
  column :body, :text
end

Use relationships.

class MessagesController < ApplicationController
  def index
    @messages = current_user.messages.from(1.week.ago).limit(10)
  end

  def create
    User.find(params[:id]).messages.create!(
      sender_id: current_user.id,
      body: params[:body]
    )
  end
end

Use it with

  • Ruby 1.9, 2.0, 2.1
  • Rails 3, Rails 4, or no Rails
  • Cassandra 1.2 or 2.0

Learn more

Fork me on GitHub