{"id":20687870,"url":"https://github.com/cribbles/activerecordlite","last_synced_at":"2025-06-19T08:33:34.460Z","repository":{"id":94979071,"uuid":"41607401","full_name":"cribbles/ActiveRecordLite","owner":"cribbles","description":"Lightweight SQLite ORM","archived":false,"fork":false,"pushed_at":"2015-09-29T23:27:34.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-17T16:52:32.983Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cribbles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-29T21:10:39.000Z","updated_at":"2016-06-20T19:02:23.000Z","dependencies_parsed_at":"2023-03-07T18:45:27.575Z","dependency_job_id":null,"html_url":"https://github.com/cribbles/ActiveRecordLite","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/cribbles%2FActiveRecordLite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cribbles%2FActiveRecordLite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cribbles%2FActiveRecordLite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cribbles%2FActiveRecordLite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cribbles","download_url":"https://codeload.github.com/cribbles/ActiveRecordLite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242945838,"owners_count":20210762,"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":[],"created_at":"2024-11-16T22:58:29.978Z","updated_at":"2025-03-10T23:59:10.198Z","avatar_url":"https://github.com/cribbles.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveRecordLite\n\n## Summary\n\nActiveRecordLite is an ORM that maps SQLite queries onto Ruby objects. It aims\nto provide an austere, yet full-featured alternative to ActiveRecord without\nall\nthe overhead.\n\n## Demo\n\n1. Clone the repo\n2. Head into `irb` or `pry`\n3. `load './demo.rb'`\n4. Go wild (using [`demo.rb`](./demo.rb) as a reference)\n\n## Libraries\n\n- SQLite3 (gem)\n- ActiveSupport::Inflector\n\n## Features\n\n- Replicates core functionality of ActiveRecord::Base and\nActiveRecord::Relation\n(as [`SQLObject`](/lib/sql_object.rb) and\n[`SQLRelation`](/lib/sql_relation.rb))\n- Super friendly API - most SQLObject and SQLRelation enumerative methods will\naccept params or a block as an argument\n- SQLRelation search parameters are stackable and lazily-evaluated - i.e.\n`Cat.all.where(name: \"Rocco\").where(owner_id: 2)` won't fire off a SQL query\nuntil you call `#count`, `#force`, `#limit`, etc.\n\n## API\n\nSQLObject provides a few of your favorite ActiveRecord associations:\n\n- `has_many`\n- `belongs_to`\n- `has_one_through`\n\nSQLObject provides all your favorite ActiveRecord methods:\n\n- `::count`\n- `::find`\n- `::where`\n- `::delete_all`\n- `::update_all`\n- `#save`\n- `#create`\n- `#update`\n- `#destroy`\n\nSQLRelation provides all your favorite `Enumerable` methods:\n\n- `#\u003c\u003c`\n- `#all?`\n- `#any?`\n- `#count`\n- `#empty?`\n- `#first`\n- `#last`\n- `#none?`\n- `#one?`\n\nSQLObject [delegates enumerable methods](/lib/sql_object.rb#L53) (along with\n`::find`, `::where`, `::delete_all` and `::update_all`) to SQLRelation. For\nexample, `Cat.any?` will iterate over the entire `cats` table and return an\nSQLRelation instance.\n\nSQLObject utility methods conventionally return an SQLRelation instance as a\ncollection object. This means you can chain methods like so:\n`Cat.where(owner_id: 1).update_all(owner_id: 2).find(1)`.\n\n## How It Works\n\nSQLObject and SQLRelation make reference to\n[`DBConnection`](/lib/db_connection.rb), which delegates SQLite::Database\ninstance methods like `#execute`, `#get_first_row`, `#last_insert_row_id`, etc.\nto a singleton instance of SQLite::Database. Consumers of the API specify this\ninstance by calling `DBConnection::open(file)`, providing an SQLite db file path\nas an argument.\n\nSQLObject and SQLRelation provide a utility belt of class/instance methods that\nmap to SQL queries. You can make use of the SQLObject API by creating a class\nthat inherits from it (see [`demo.rb`](./demo.rb) for an example).\n\nAssociations (`has_many`, `belongs_to`, `has_one_through`) are dynamically\ngenerated by the [`Associatable`](./lib/associatable.rb) module, which extends\nSQLObject. Associations infer `class_name`, `foreign_key` and `primary_key`\nbased on the same conventions as ActiveRecord. You can override these if the\ndatabase schema you're working with is non-compliant (or\nActiveSupport::Inflector fails to guess your table name).\n\n## Notes\n\nActiveSupport::Inflector isn't a hard dependency; it's really only used in\n[`has_many`](./lib/has_many_options.rb), to provide sensible `class_name`\nand `foreign_key` defaults (see above).\n\nIf you _really_ want to trim overhead, you can get away with declaring options\nfor these manually in your association definitions.\n\n## License\n\nActiveRecordLite is released under the [MIT License](/LICENSE).\n\n---\nDeveloped by [Chris Sloop](http://chrissloop.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcribbles%2Factiverecordlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcribbles%2Factiverecordlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcribbles%2Factiverecordlite/lists"}