{"id":22025174,"url":"https://github.com/drexed/lite-query","last_synced_at":"2026-04-18T02:04:46.072Z","repository":{"id":35094635,"uuid":"205924858","full_name":"drexed/lite-query","owner":"drexed","description":"Ruby Query based framework (aka query objects)","archived":false,"fork":false,"pushed_at":"2023-01-19T01:39:25.000Z","size":56,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T22:38:30.568Z","etag":null,"topics":["query","ruby"],"latest_commit_sha":null,"homepage":"https://drexed.github.io/lite-query","language":"Ruby","has_issues":false,"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/drexed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-02T19:38:37.000Z","updated_at":"2022-11-19T22:55:20.000Z","dependencies_parsed_at":"2023-02-10T19:30:25.115Z","dependency_job_id":null,"html_url":"https://github.com/drexed/lite-query","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/drexed/lite-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drexed","download_url":"https://codeload.github.com/drexed/lite-query/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-query/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31953517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["query","ruby"],"created_at":"2024-11-30T07:14:48.290Z","updated_at":"2026-04-18T02:04:46.044Z","avatar_url":"https://github.com/drexed.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lite::Query\n\n[![Gem Version](https://badge.fury.io/rb/lite-query.svg)](http://badge.fury.io/rb/lite-query)\n[![Build Status](https://travis-ci.org/drexed/lite-query.svg?branch=master)](https://travis-ci.org/drexed/lite-query)\n\nLite::Query is a library for using the query pattern to separate complex query\nlogic from classes such as controllers and models.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lite-query'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install lite-query\n\n## Table of Contents\n\n* [Setup](#setup)\n* [Usage](#usage)\n\n## Setup\n\n#### Generators\n\n`rails g query NAME` will generate the following file in your application root:\n\n```erb\napp/queries/[NAME]_query.rb\n```\n\nIf a `ApplicationQuery` file in the `app/queries` directory is available, the\ngenerator will create file that inherit from `ApplicationQuery` if not it will\nfallback to `Lite::Query::Base`.\n\n#### Query\n\nYou will need to fill this class with the required `call` method as shown below:\n\n```ruby\nclass AgeQuery \u003c Lite::Query::Base\n\n  def call\n    return relation unless args[:age]\n\n    relation.where('age \u003e ?', args[:age])\n  end\n\nend\n```\n\n## Usage\n\nThere are multiple ways to access the query call:\n\n#### Instance\n```ruby\nrelation = User.limit(1)\nquery = AgeQuery.new(relation, age: 10)\nquery.call #=\u003e SELECT * FROM users WHERE age = 10 LIMIT 1\n```\n\n#### Class\n```ruby\nAgeQuery.call(User, age: 20) #=\u003e SELECT * FROM users WHERE age = 10\n```\n\n#### Scope\n```ruby\nclass User \u003c ApplicationRecord\n\n  scope :min_age, -\u003e(age) { MinAgeQuery.new(self, age: age) }\n\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/drexed/lite-query. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Lite::Query project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/drexed/lite-query/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrexed%2Flite-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-query/lists"}