{"id":13879652,"url":"https://github.com/digital-fabric/eno","last_synced_at":"2025-04-23T14:05:10.434Z","repository":{"id":62558082,"uuid":"166016053","full_name":"digital-fabric/eno","owner":"digital-fabric","description":"Eno's Not an ORM","archived":false,"fork":false,"pushed_at":"2024-05-01T10:16:24.000Z","size":106,"stargazers_count":21,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-14T05:49:00.116Z","etag":null,"topics":["database","dsl","orm","ruby","sql"],"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/digital-fabric.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2019-01-16T09:54:08.000Z","updated_at":"2024-11-25T11:38:48.000Z","dependencies_parsed_at":"2024-01-13T20:57:35.642Z","dependency_job_id":"8c5344ab-5e57-4c3e-b9ee-5e2147d28245","html_url":"https://github.com/digital-fabric/eno","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.30000000000000004","last_synced_commit":"d1d5c35cb62ba1d31061c335fe1782899b65be61"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digital-fabric%2Feno","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digital-fabric%2Feno/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digital-fabric%2Feno/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digital-fabric%2Feno/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digital-fabric","download_url":"https://codeload.github.com/digital-fabric/eno/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250447900,"owners_count":21432164,"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":["database","dsl","orm","ruby","sql"],"created_at":"2024-08-06T08:02:27.817Z","updated_at":"2025-04-23T14:05:10.393Z","avatar_url":"https://github.com/digital-fabric.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Eno - the SQLite Toolkit for Ruby\n\n\u003ch2 style=\"align: center\"\u003eEno's Not an ORM\u003c/h2\u003e\n\n[INSTALL](#installing-eno) |\n[TUTORIAL](#getting-started) |\n[EXAMPLES](examples)\n\n## What is Eno?\n\nEno is a Ruby gem for working with SQLite databases in Ruby. Eno provides a set\nof tools for implementing various persistence and data access patterns using the\nSQLite embedded database engine.\n\nFeatures:\n\n- Out of the box support for concurrent database access.\n- Automatic connection pooling, with support for thread- and fiber-based\n  concurrency.\n- Data stores with specialized APIs for different data access patterns.\n- DSL for expressing SQL queries with support for CTEs and window functions.\n- Based on [Extralite].\n\n## Synopsis\n\n```ruby\nEno.connect '/path/to/my.db'\n\n# define a query\nq = Q {\n  select :*\n  from foo\n}\n# or alternatively\nq = Eno.q { select_all; from foo }\n\n# query mutation\nQ.from(:foo).select_all\n\n# get all rows\nq.to_a\n\n# iterate through records\nq.each { |r| ... }\n\n# mutate query\nq.where { bar == 42 }.to_a\n\n# count records\nq.where { bar == 42 }.count\n# which is short for:\nq.where { bar == 42 }.select { count(:*) }.single_value\n\n# parametrized queries\nq = Q {\n  select_all\n  from foo\n  where bar == _(bar)\n}\n\nq.to_a(bar: 42)\n\nclass Post \u003c Eno::ModelStore\n  schema(:post) do\n    column id:      integer, :primary_ke\n    column user_id: integer\n    column title:   text\n    column body:    text\n\n    foreign_key user_id: [:users, :id]\n  end\nend\n\nclass User \u003c Eno::ModelStore\n  schema(:user) do\n    column id:    integer, :primary_key\n    column name:  text\n  end\n\n  one_to_many :posts do\n    left join post\n    on post.user_id == user.id\n    order_by post.id\n  end\n\n  def posts\n    this = self\n    Post.where { user_id.in this.select { id } }\n  end\nend\n\nh = User.insert(name: 'foo')\nh.class #=\u003e Hash\nh[:id] #=\u003e 1\nh[:name] #=\u003e 'foo'\n\nu = User[1]\nu #=\u003e User \u003cwhere id = 1\u003e\nname = u.values[:name]\n\nu.update(name: 'bar')\n\nposts = u.posts\nposts.class #=\u003e Post\n\nposts.each do |r|\n  puts r.title\n  puts r.body\nend\n\n# checkout a connection explicitly and wrap in a transaction:\nEno.transaction do\n  Posts.where { user_id == 3 }.update(user_id: nil)\n  User[3].delete\nend\n\n# protection against updating/deleting without a where clause\nUser.delete\n#=\u003e Eno::Error 'To delete all records use the #all modifier, e.g. foo.all.delete'\nUser.all.delete #=\u003e 1\n\n# custom modifiers\nclass Post \u003c Eno::ModelStore\n  ...\n\n  def by_category(category)\n    where(category:)\n  end\n\n  def published\n    where(published: true)\n  end\nend\n\nfoo_posts = Post.published.by_category('foo')\n\nfoo_posts.where_clause\n#=\u003e \"where (published is true) and (category = 'foo')\"\n\n# Key-value store\ncache = Eno::KVStore.new('cache')\ncache.set('foo', 'bar')\n\n# set TTL of 30 seconds\ncache.setex('foo', 30, 'baz')\n\n# periodic cache eviction\nbouncer = Thread.new do\n  loop do\n    sleep 10\n    cache.evict_expired_keys\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigital-fabric%2Feno","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigital-fabric%2Feno","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigital-fabric%2Feno/lists"}