{"id":32166829,"url":"https://github.com/tanweerdev/fat_ecto","last_synced_at":"2026-02-19T07:02:47.737Z","repository":{"id":33274677,"uuid":"154666128","full_name":"tanweerdev/fat_ecto","owner":"tanweerdev","description":"Query mechanism for Ecto ","archived":false,"fork":false,"pushed_at":"2025-11-04T10:58:20.000Z","size":567,"stargazers_count":31,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-25T06:13:23.357Z","etag":null,"topics":["ecto","elixir-library","query-language","query-mechanism","utils"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/fat_ecto","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/tanweerdev.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-10-25T12:21:29.000Z","updated_at":"2025-11-28T11:43:39.000Z","dependencies_parsed_at":"2023-10-12T17:11:10.507Z","dependency_job_id":"8dbfdb7a-c595-40e4-94d0-559810e8f41c","html_url":"https://github.com/tanweerdev/fat_ecto","commit_stats":{"total_commits":279,"total_committers":5,"mean_commits":55.8,"dds":0.2114695340501792,"last_synced_commit":"e3af5787bd4a7ee347baf6c9aab3c87947524361"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tanweerdev/fat_ecto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanweerdev%2Ffat_ecto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanweerdev%2Ffat_ecto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanweerdev%2Ffat_ecto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanweerdev%2Ffat_ecto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanweerdev","download_url":"https://codeload.github.com/tanweerdev/fat_ecto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanweerdev%2Ffat_ecto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29605803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ecto","elixir-library","query-language","query-mechanism","utils"],"created_at":"2025-10-21T15:11:49.536Z","updated_at":"2026-02-19T07:02:47.732Z","avatar_url":"https://github.com/tanweerdev.png","language":"Elixir","readme":"# FatEcto: Supercharge Your Ecto Queries with Ease! 🚀\n\n[![Build Status](https://github.com/tanweerdev/fat_ecto/actions/workflows/fat_ecto.yml/badge.svg)](https://github.com/tanweerdev/fat_ecto/actions)\n[![Coverage Status](https://coveralls.io/repos/github/tanweerdev/fat_ecto/badge.svg)](https://coveralls.io/github/tanweerdev/fat_ecto)\n[![hex.pm version](https://img.shields.io/hexpm/v/fat_ecto.svg)](https://hex.pm/packages/fat_ecto)\n[![hex.pm downloads](https://img.shields.io/hexpm/dt/fat_ecto.svg)](https://hex.pm/packages/fat_ecto)\n[![hex.pm license](https://img.shields.io/hexpm/l/fat_ecto.svg)](https://github.com/tanweerdev/fat_ecto/blob/master/LICENSE)\n[![Last Updated](https://img.shields.io/github/last-commit/tanweerdev/fat_ecto.svg)](https://github.com/tanweerdev/fat_ecto/commits/master)\n\n---\n\n## Description\n\nFatEcto is an Elixir package designed to make your life easier when working with Ecto. It simplifies query building, filtering, sorting, and pagination—so you can focus on what truly matters: building amazing applications. With FatEcto, writing complex repeating queries becomes effortless, flexible, and powerful! 💪\n\n---\n\n## Installation\n\nAdd `fat_ecto` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    # Check https://hexdocs.pm/fat_ecto for the latest version\n    {:fat_ecto, \"~\u003e 1.2\"}\n  ]\nend\n```\n\nThen, run `mix deps.get` to install the package.\n\n---\n\n## Features \u0026 Modules\n\n### 🛠 FatEcto.Query.Dynamics.Buildable – Dynamic Filtering Made Easy\n\nTired of writing repetitive query filters? The `Whereable` module lets you dynamically filter records using flexible conditions passed from your web or mobile clients—with little to no effort! And the best part? You stay in control. 🚀\n\n#### Usage\n\n```elixir\ndefmodule FatEcto.HospitalDynamicsBuilder do\n  use FatEcto.Query.Dynamics.Buildable,\n    filterable: [\n      id: [\"$EQUAL\", \"$NOT_EQUAL\"]\n    ],\n    overrideable: [\"name\", \"phone\"],\n    ignoreable: [\n      name: [\"%%\", \"\", [], nil],\n      phone: [\"%%\", \"\", [], nil]\n    ]\n\n  import Ecto.Query\n\n  @impl true\n  # You can implement override_buildable for your custom filters\n  def override_buildable(\"name\", \"$ILIKE\", value) do\n    dynamic([r], ilike(fragment(\"(?)::TEXT\", r.name), ^value))\n  end\n\n  def override_buildable(_field, _operator, _value), do: nil\nend\n```\n\n---\n\n#### Example Usage\n\nHere are some practical examples of how to use `FatEcto.HospitalDynamicsBuilder` to dynamically build queries:\n\n##### Example 1: Basic Filtering by ID\n\n```elixir\n# Filter hospitals with ID equal to 1\nparams = %{\"id\" =\u003e %{\"$EQUAL\" =\u003e 1}}\ndynamics = FatEcto.HospitalDynamicsBuilder.build(params)\n\n# Use the dynamics in a query\nimport Ecto.Query\nquery = where(FatEcto.FatHospital, ^dynamics)\n\n# Resulting query:\n# from(h in FatEcto.FatHospital, where: h.id == 1)\n```\n\n##### Example 2: Case-Insensitive Name Search\n\n```elixir\n# Filter hospitals with names containing \"St. Mary\"\nparams = %{\"name\" =\u003e %{\"$ILIKE\" =\u003e \"%St. Mary%\"}}\ndynamics = FatEcto.HospitalDynamicsBuilder.build(params)\n\n# Use the dynamics in a query\nimport Ecto.Query\nquery = where(FatEcto.FatHospital, ^dynamics)\n\n# Resulting query:\n# from(h in FatEcto.FatHospital, where: ilike(fragment(\"(?)::TEXT\", h.name), ^\"%St. Mary%\"))\n```\n\n##### Example 3: Combining Multiple Filters\n\n```elixir\n# Filter hospitals with ID not equal to 2 AND name containing \"General\"\nparams = %{\n  \"id\" =\u003e %{\"$NOT_EQUAL\" =\u003e 2},\n  \"name\" =\u003e %{\"$ILIKE\" =\u003e \"%General%\"}\n}\ndynamics = FatEcto.HospitalDynamicsBuilder.build(params)\n\n# Use the dynamics in a query\nimport Ecto.Query\nquery = where(FatEcto.FatHospital, ^dynamics)\n\n# Resulting query:\n# from(h in FatEcto.FatHospital, where: h.id != 2 and ilike(fragment(\"(?)::TEXT\", h.name), ^\"%General%\"))\n```\n\n##### Example 4: Ignoring Empty or Invalid Values\n\n```elixir\n# Filter hospitals with a name, but ignore empty or invalid values\nparams = %{\"name\" =\u003e %{\"$ILIKE\" =\u003e \"%%\"}}  # Empty value is ignored\ndynamics = FatEcto.HospitalDynamicsBuilder.build(params)\n\n# Use the dynamics in a query\nimport Ecto.Query\nquery = where(FatEcto.FatHospital, ^dynamics)\n\n# Resulting query:\n# from(h in FatEcto.FatHospital)  # No filtering applied for name\n```\n\n##### Example 5: Even Complex Nested conditions\n\n```elixir\n# Filter hospitals with a name, but ignore empty or invalid values\nparams = %{\n  \"$OR\" =\u003e [\n    %{\n      \"name\" =\u003e %{\"$ILIKE\" =\u003e \"%John%\"},\n      \"$OR\" =\u003e %{\"rating\" =\u003e %{\"$GT\" =\u003e 18}, \"location\" =\u003e \"New York\"}\n    },\n    %{\n      \"start_date\" =\u003e \"2023-01-01\",\n      \"$AND\" =\u003e [\n        %{\"rating\" =\u003e %{\"$GT\" =\u003e 4}},\n        %{\"email\" =\u003e \"fat_ecto@example.com\"}\n      ]\n    }\n  ]\n}\n\ndynamics = DoctorFilter.build(params)\n\n# Resulting dynamic:\ndynamic(\n  [q],\n  ((q.location == ^\"New York\" or q.rating \u003e ^18) and ilike(fragment(\"(?)::TEXT\", q.name), ^\"%John%\")) or\n    (q.rating \u003e ^4 and q.email == ^\"fat_ecto@example.com\" and q.start_date == ^\"2023-01-01\")\n)\n\n# You can now apply the result on where just like above examples\n```\n\n##### Example 6: Global Configuration for Default Dynamics\n\nConfigure FatEcto to return `dynamic([q], true)` instead of `nil` when no filters are applied:\n\n```elixir\n# config/config.exs\nconfig :fat_ecto, :default_dynamic, :return_true\n\n# Now all Buildable modules return dynamic([q], true) when filters are empty\ndynamics = FatEcto.HospitalBuilder.build(%{})\n# Returns: dynamic([q], true) instead of nil\n```\n\n---\n\n### 🔄 FatEcto.Sort.Sortable – Effortless Sorting\n\nSorting should be simple—and with `Sortable`, it is! Your frontend can send sorting parameters, and FatEcto will seamlessly generate the right sorting queries, allowing you to build powerful, customizable sorting logic without breaking a sweat. 😎\n\n#### Usage of FatSortable\n\n```elixir\ndefmodule Fat.SortQuery do\n  import Ecto.Query\n  use FatEcto.Sort.Sortable,\n    sortable: [id: \"$ASC\", email: \"*\", name: [\"$ASC\", \"$DESC\"]],\n    overrideable: [\"custom_field\"]\n\n  @impl true\n  def override_sortable(\"custom_field\", \"$DESC\") do\n    {:desc, dynamic([u], fragment(\"?-\u003e\u003e'custom_field'\", u.metadata))}\n  end\n\n  def override_sortable(_field, _operator), do: nil\nend\n```\n\n---\n\n### 📌 FatEcto.Pagination.Paginator – Paginate Like a Pro\n\nNo more hassle with pagination! FatPaginator helps you paginate Ecto queries efficiently, keeping your APIs snappy and responsive.\n\n#### Usage of FatPaginator\n\n```elixir\ndefmodule Fat.MyPaginator do\n  use FatEcto.Pagination.V2Paginator,\n    default_limit: 10,\n    repo: FatEcto.Repo,\n    max_limit: 100\nend\n```\n\n---\n\n## 🚀 Contributing\n\nWe love contributions! If you’d like to improve FatEcto, submit an issue or pull request. Let’s build something amazing together! 🔥\n\n---\n\n## 📜 License\n\nFatEcto is released under the MIT License.\n\n📖 See the full documentation at [HexDocs](https://hexdocs.pm/fat_ecto/) for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanweerdev%2Ffat_ecto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanweerdev%2Ffat_ecto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanweerdev%2Ffat_ecto/lists"}