BaseRecord is a lightweight Ruby object relational mapping (ORM) library that is based on Rails' ActiveRecord. It translates rows from a sqlite3 database into Ruby objects while maintaining readability and DRYness of your code.
It incorporates metaprogramming techniques, and allows you to perform database operations in an object-oriented manner without having to write SQL code!
- Implements the core functionality of ActiveRecord::Base.
- Follows Ruby's 'convention over configuration' paradigm.
- Utilizes sqlite3 (gem) and ActiveSupport::Inflector libraries.
- Supports ActiveRecord's core associations,
belongs_to
,has_many
, andhas_one_through
, providing sensible default class_name, foreign_key, and primary_key values if not provided by user.
- Clone this repository and
cd
to it. - Run
bundle install
. - In terminal, navigate to the folder for this repo, and then open pry or irb.
- Run
load 'musicals_demo.rb'
. - Use the API below to play around with the data.
SQLObject provides similar core ActiveRecord associations as well as other methods to query the database:
- ::columns -> Prints out a list of columns from given table
- ::all -> Finds all items
- ::where -> Fins all items that meet the query constraint
- ::parse_all -> Take in an array and turns all items into table objects
- has_many
- belongs_to
- has_one_through
- ::first
- ::last
- ::find
- ::columns -> Prints out a list of columns from given table
- ::all -> Finds all items
- ::where -> Fins all items that meet the query constraint
- ::parse_all -> Take in an array and turns all items into table objects