Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cassandra_object_rails

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cassandra_object_rails

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

== Cassandra Object Rails

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

=== Installation

Add the following to your Gemfile:

gem 'cassandra_object_rails'

=== 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 } }

=== Connecting your rails application with Cassandra

in your config/cassandra.yml

development: keyspace: 'my_app_development' servers: '127.0.0.1:9160'

test: keyspace: 'my_app_development' servers: '127.0.0.1:9160'

production: keyspace: 'my_app_development' servers: '127.0.0.1:9160'

=== 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

=== Query

Some lightweight scoping features are available:

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

=== Keyspace

Creating cassandra keyspace defined on cassandra.yml

rake cassandra:create

Droping cassandra keyspace

rake cassandra:drop

=== Adding column family

CassandraObject::Schema.create_column_family 'Widgets'

FAQs

Package last updated on 22 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc