CassandraDB
Cassandra DB adapter inspired on Sequel
Installation
Add this line to your application's Gemfile:
gem 'cassandra_db'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cassandra_db
Usage
Connect
db = CassandraDB.connect hosts: ['localhost'], port: 9042, keyspace: 'system'
Metadata
db.keyspace
db.keyspaces
db.tables
Change keyspace
db.use_keyspace 'my_keyspace'
db.keyspace
Create and drop keyspaces
replication_opts = {
class: 'SimpleStrategy',
replication_factor: 1
}
db.create_keyspace :my_keyspace, replication: replication_opts, durable_writes: true
db.drop_keyspace :my_keyspace
Queries
dataset = db[table_name]
dataset = db[table_name].where(field: 'value')
Dataset/Enumerable methods
dataset.count
dataset.each
dataset.map
dataset.all
Insert, Update, Delete
dataset.insert id: 1, name: 'Name 1'
dataset.where(id: 1).update name: 'Name 2'
dataset.where(id: 1).delete
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/cassandra_db.
License
The gem is available as open source under the terms of the MIT License.