{"id":19880244,"url":"https://github.com/joeljuca/swiss_schema","last_synced_at":"2025-04-10T00:19:57.434Z","repository":{"id":179776163,"uuid":"663088983","full_name":"joeljuca/swiss_schema","owner":"joeljuca","description":"A Swiss Army knife for your Ecto schemas","archived":false,"fork":false,"pushed_at":"2025-03-03T14:43:24.000Z","size":231,"stargazers_count":30,"open_issues_count":11,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T12:00:06.029Z","etag":null,"topics":["ecto","ecto-extension","elixir","elixir-lang","metaprogramming"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/swiss_schema","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joeljuca.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2023-07-06T14:24:34.000Z","updated_at":"2025-03-08T20:06:08.000Z","dependencies_parsed_at":"2023-10-05T04:45:51.810Z","dependency_job_id":"bf1528e3-a33e-4e58-a109-46a61eefa6bb","html_url":"https://github.com/joeljuca/swiss_schema","commit_stats":null,"previous_names":["joeljuca/swisschema","joeljuca/swiss_schema"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeljuca%2Fswiss_schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeljuca%2Fswiss_schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeljuca%2Fswiss_schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeljuca%2Fswiss_schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeljuca","download_url":"https://codeload.github.com/joeljuca/swiss_schema/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131686,"owners_count":21052895,"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":["ecto","ecto-extension","elixir","elixir-lang","metaprogramming"],"created_at":"2024-11-12T17:10:42.326Z","updated_at":"2025-04-10T00:19:57.413Z","avatar_url":"https://github.com/joeljuca.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwissSchema\n\n[![Licensed under Apache 2.0](https://img.shields.io/hexpm/l/swiss_schema)](LICENSE)\n[![Hex version](https://img.shields.io/hexpm/v/swiss_schema)](https://hex.pm/packages/swiss_schema)\n[![CI status](https://github.com/joeljuca/swiss_schema/actions/workflows/main.yml/badge.svg)](https://github.com/joeljuca/swiss_schema/actions/workflows/main.yml)\n[![Joel Jucá on LinkedIn](https://img.shields.io/badge/%2Fjoeljuca-blue?logo=linkedin \"Joel Jucá on LinkedIn\")](https://www.linkedin.com/in/joeljuca \"Joel Jucá on LinkedIn\")\n\n**A Swiss Army knife for your Ecto schemas**\n\nSwissSchema is a query toolkit for Ecto schemas. It makes it easy to manipulate data using Ecto schemas by implementing relevant Ecto.Repo [Query API](https://hexdocs.pm/ecto/Ecto.Repo.html#query-api) and [Schema API](https://hexdocs.pm/ecto/Ecto.Repo.html#schema-api) functions, pre-configured to work specifically with the given Ecto schema.\n\n## Setup\n\nAdd `swiss_schema` as a dependency in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    # ...\n    {:swiss_schema, \"~\u003e 0.6\"}\n  ]\nend\n```\n\nThen, `use SwissSchema` in your Ecto schemas:\n\n```elixir\n# lib/my_app/accounts/user.ex\n\ndefmodule MyApp.Accounts.User do\n  use Ecto.Schema\n  use SwissSchema, repo: MyApp.Repo\n\n  def changeset(%User{} = user, params) do\n    # here you set up your schema's changeset as usual\n  end\nend\n```\n\nThat's it, you should be good to go.\n\n## Usage\n\nWhen you `use SwissSchema`, a collection of pre-configured functions will be added to your Ecto schema module. The functions are equivalent to two important Ecto.Repo APIs: the [Query API](https://hexdocs.pm/ecto/Ecto.Repo.html#query-api) and the [Schema API](https://hexdocs.pm/ecto/Ecto.Repo.html#schema-api).\n\n```elixir\niex\u003e User.get(1)\n{:ok, %User{id: 1, ...}}\n\niex\u003e User.get_by(email: \"john@smiths.net\")\n{:ok, %User{id: 2, email: \"john@smiths.net\", ...}}\n```\n\nThe motivation to have such API directly in your Ecto schema is to make function calls more idiomatic.\n\n[Check the docs](https://hexdocs.pm/swiss_schema) for a complete list of available functions.\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## FAQ\n\nSee: [FAQ.md](FAQ.md).\n\n## Alternatives\n\nIt seems that I'm not the only person in the world trying to improve this immediate Ecto's querying DX. Recently, I found some other projects similar to SwissSchema that creates some sort of querying tools out of Ecto schemas:\n\n- **[Bee](https://hex.pm/packages/bee)** by [Helder de Sousa](https://github.com/andridus) 🇧🇷\n- **[Ecto.Entity](https://hex.pm/packages/ecto_entity)** by [Kamaro Lambert](https://github.com/kamaroly) 🇰🇪\n- **[EctoQuerify](https://hex.pm/packages/ecto_querify)** by [Marko Bogdanović](https://github.com/bmarkons) 🇷🇸\n\n## License\n\n\u0026copy; 2023 Joel Jucá. Licensed under [Apache License 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeljuca%2Fswiss_schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeljuca%2Fswiss_schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeljuca%2Fswiss_schema/lists"}