Project

omnidata

0.0
No commit activity in last 3 years
No release in over 3 years
Omnidata let you define your model free from any specific database.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8.3
~> 3.12
~> 2.8.0

Runtime

active_support
>= 0
>= 0
 Project Readme

omnidata

warning: Currently in super alpha stage, everything's subjected to change.

Omnidata allows you to define your models in persistence agnostic fashion, so model can be saved in any database you like, mongodb, couchdb etc.

Gem uses Virtus for defining attributes.

For example, to define the database and model.

Omnidata.setup_database(:db1, {:adapter => 'mongodb', :database => 'mydb'})
Omnidata.setup_database(:db2, {:adapter => 'mongodb', :database => 'mydb2'})

class User
  include Omnidata::Model
  use_database :db1

  attribute :name, String
  attribute :age, Integer

  index :age
end

Typical query usage

user = User.new(:name => 'Jack Hunt', :age => 27)
user.save
User.find(user.id)

User.find  # return all users

User.count
User.find(:limit => 10, :skip => 10)    # paginated query

User.find(:order => :age)      # sort by age

Switch to another db temporarily.

User.with_database(:db2) do
  User.find(user.id)
end