{"id":24434127,"url":"https://github.com/tfwright/agar","last_synced_at":"2026-02-09T13:16:49.984Z","repository":{"id":51493923,"uuid":"355362640","full_name":"tfwright/agar","owner":"tfwright","description":"Dynamic query aggregation for Ecto","archived":false,"fork":false,"pushed_at":"2022-10-10T23:20:52.000Z","size":37,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-02T00:22:35.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/tfwright.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}},"created_at":"2021-04-07T00:09:33.000Z","updated_at":"2024-05-02T00:22:35.509Z","dependencies_parsed_at":"2023-01-19T18:18:44.232Z","dependency_job_id":null,"html_url":"https://github.com/tfwright/agar","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/tfwright%2Fagar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfwright%2Fagar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfwright%2Fagar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfwright%2Fagar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfwright","download_url":"https://codeload.github.com/tfwright/agar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234823645,"owners_count":18892367,"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":"2025-01-20T16:54:25.528Z","updated_at":"2025-10-01T04:31:29.531Z","avatar_url":"https://github.com/tfwright.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Agar\n\nDynamically build aggregate queries in Ecto from simple configs that can easily be encoded as URL params.\n\n## Usage\n\n```\nMySchema.aggregate(\n  fields: [:name, :email, some_assoc: :id],\n  assocs: [other_assocs: [numeric_field: [:sum, :avg]]],\n)\n=\u003e [%{\"name\" =\u003e \"hi\", \"email\" =\u003e \"email@example.com\", \"other_assoc_numeric_field_avg\" =\u003e 3, \"other_assoc_numeric_field_sum\" =\u003e 10}]\n```\n\nor: `MySchema.aggregate([\"name\", \"email\", \"some_assoc_id\", \"sum_other_assocs_numeric_field\", \"avg_other_assocs_numeric_field\"])`\n\nIn the former version, you can use any association and any field defined on the schemas. In the latter, only associations that themselves use Agar and fields specified in the whitelist option will be permitted, as shown below. Other values will cause an error.\n\n```\ndefmodule MySchema do\n  use Agar, whitelist: [:name, :email]\n\n  #...\n\n  belongs_to :some_assoc, AssocSchema\n  has_many :other_assocs, OtherAssocSchema\nend\n\ndefmodule AssocSschema do\n  use Agar, whitelist: [:id]\nend\n\ndefmodule OtherAssocSchema do\n  use Agar, whitelist: [:numeric_field]\nend\n```\n\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `agar` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:agar, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Development\n\n* Prepare test database: `MIX_ENV=test mix do ecto.create, ecto.migrate`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfwright%2Fagar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfwright%2Fagar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfwright%2Fagar/lists"}