{"id":23170348,"url":"https://github.com/mkonikov/dynamicbase","last_synced_at":"2025-07-16T10:42:08.838Z","repository":{"id":88672528,"uuid":"102493972","full_name":"mkonikov/DynamicBase","owner":"mkonikov","description":"DynamicBase is a lightweight object-relational mapping tool built with Ruby.","archived":false,"fork":false,"pushed_at":"2017-09-14T13:48:06.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T07:42:39.776Z","etag":null,"topics":["ruby","sql","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkonikov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-05T14:48:13.000Z","updated_at":"2017-09-06T14:03:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"25f59967-2eaa-4897-921d-502b3e723b28","html_url":"https://github.com/mkonikov/DynamicBase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkonikov%2FDynamicBase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkonikov%2FDynamicBase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkonikov%2FDynamicBase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkonikov%2FDynamicBase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkonikov","download_url":"https://codeload.github.com/mkonikov/DynamicBase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261603,"owners_count":20910108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","sql","sqlite3"],"created_at":"2024-12-18T03:26:50.200Z","updated_at":"2025-04-04T23:15:21.635Z","avatar_url":"https://github.com/mkonikov.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DynamicBase\n\nDynamicBase is a lightweight object-relational mapping tool built with Ruby. By creating a subclass of the `Base` class, existing tables in the database are mapped to these new classes.\n\n## Example Usage\nUsing the sample database as an example, one can retrieve the NYC attractions in the Bronx by running `Borough.first.sights`. To change a property, for example the name, one can simply type\n```ruby\nbronx = Borough.first\nbronx.name = 'The Bronx'\nbronx.save\n```\n\n## Features\n[Base](#base)\n* [`::all`](#all)\n* [`::first`](#first)\n* [`::last`](#last)\n* [`::find`](#find)\n* [`::new`](#new)\n* [`::save`](#save)\n\n[Searchable](#searchable)\n* [`::where`](#where)\n\n[Associations](#associations)\n* [`::belongs_to`](#belongs_to)\n* [`::has_many`](#has_many)\n* [`::has_one_through`](#has_one_through)\n\n### Base\n#### `all`\n\nWill return an array of all entries in the database for the specified table.\n\nExample: `Borough.all`\n\n#### `first`\n\nWill return the first database entry for the specified table (ordered by id).\n\nExample: `Borough.first`\n\n#### `last`\n\nWill return the last database entry for the specified table (ordered by id).\n\nExample: `Borough.last`\n\n#### `find(id)`\n\nWill return the entry in the database with the id matching the argument.\n\nExample: `Borough.find(4)`\n\n#### `new`\n\nCreates a new Base object (which can be modified and then update or insert intothe database with the save method below)\n\nExample: `Borough.new`\n\n#### `save`\n\nDepending on if entry exists in database, will either update or insert into database.\n\nExample:\n```ruby\nborough = Borough.new\nborough.name = \"Queens\"\nborough.save\n```\n\n### Searchable\n#### `where`\n\nReturns the results of a SQL query based on the hash parameters passed in as arguments.\n\nExample: `Borough.where(name: \"Manhattan\")`\n\n### Associations\n#### `belongs_to`\n\nWill return base object with the child associated with the selected object.\n\nExample: `Neighborhood.first.borough`\n\n#### `has_many`\n\nWill return base object with the parent associated with the selected object.\n\nExample: `Borough.first.neighborhoods`\n\n#### `has_one_through`\n\nWill return base object with the grandparent associated with the selected object.\n\nExample: `Sight.first.borough`\n\n\n## Demo\nA sample database is included. To run simply clone this repo and open with pry or IRB with the `load 'demo/nyc.rb'` command.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkonikov%2Fdynamicbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkonikov%2Fdynamicbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkonikov%2Fdynamicbase/lists"}