Experimental basic ORM in Ruby that only support SQLite3.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install lite_record
require 'lite_record' LiteRecord.configure('path_to_sqlite3_database.db')
Create a model class that inherits from
LiteRecord::Base and that's it.
# Table: users(id, name, email) class User < LiteRecord::Base self.table = 'users' end u = User.create('name' => 'john', 'email'=> 'firstname.lastname@example.org') # creates a database record u['name'] = 'wick' u.save # update the user with the new name in the database u = User.find(1) # query the user with id = 1 u = User.new('name' => 'foo') # creates a user object u['email'] = 'email@example.com' u.save # creates a user record # Creates a database record
You're more than welcome to improve this work.
The gem is available as open source under the terms of the MIT License.