{"id":16767096,"url":"https://github.com/davydog187/ecto_range","last_synced_at":"2026-03-08T09:37:01.916Z","repository":{"id":99742520,"uuid":"549272825","full_name":"davydog187/ecto_range","owner":"davydog187","description":"An Ecto custom type for working Postgres ranges","archived":false,"fork":false,"pushed_at":"2023-05-04T02:13:09.000Z","size":50,"stargazers_count":26,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-14T04:55:42.134Z","etag":null,"topics":["ecto","elixir","postgres","ranges"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/ecto_range/","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/davydog187.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":"2022-10-11T00:04:13.000Z","updated_at":"2024-11-01T13:10:58.000Z","dependencies_parsed_at":"2023-06-28T20:00:13.204Z","dependency_job_id":null,"html_url":"https://github.com/davydog187/ecto_range","commit_stats":null,"previous_names":["bitfo/ectorange"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davydog187%2Fecto_range","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davydog187%2Fecto_range/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davydog187%2Fecto_range/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davydog187%2Fecto_range/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davydog187","download_url":"https://codeload.github.com/davydog187/ecto_range/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244166744,"owners_count":20409179,"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","elixir","postgres","ranges"],"created_at":"2024-10-13T06:08:26.478Z","updated_at":"2025-12-12T00:13:41.735Z","avatar_url":"https://github.com/davydog187.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EctoRange\n\n[![Build Status](https://github.com/bitfo/ectorange/workflows/CI/badge.svg?branch=main)](https://github.com/bitfo/ectorange/actions) [![Hex pm](https://img.shields.io/hexpm/v/ecto_range.svg?style=flat)](https://hex.pm/packages/ecto_range) [![Hexdocs.pm](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ecto_range/) [Changelog](https://github.com/davydog187/ecto_range/blob/main/CHANGELOG.md)\n\n\u003c!-- MDOC !--\u003e\n\n`EctoRange` is a tiny library that provides Ecto custom types for all [Postgres Range types](https://www.postgresql.org/docs/current/rangetypes.html).\n\nThe main design goal of `EctoRange` is to be easy to use with native Elixir types,\nwhile providing the full flexibility of Postgres Range types inside of Ecto.\n\n| Postgres type | `Ecto.Type`             |\n| ------------- | ----------------------- |\n| int4range     | `EctoRange.Int4`        |\n| int8range     | `EctoRange.Int8`        |\n| numrange      | `EctoRange.Num`         |\n| tsrange       | `EctoRange.Timestamp`   |\n| tstzrange     | `EctoRange.TimestampTZ` |\n| daterange     | `EctoRange.Date`        |\n\n## Usage\n\n`EctoRange` provides custom types, and can be used like any other Ecto type.\n\n```elixir\ndefmodule MyApp.Repo.Migrations.AddRange do\n  use Ecto.Migration\n\n  def change do\n    create table(:my_table) do\n      add :name, :string\n      add :range, :daterange\n    end\n  end\nend\n\ndefmodule MyApp.Table do\n  use Ecto.Schema\n\n  import Ecto.Changeset\n\n  schema \"my_table\" do\n    field(:name, :string)\n    field(:range, EctoRange.Date)\n  end\n\n  def changeset(table, params) do\n    table\n    |\u003e cast(params, [:name, :range])\n    |\u003e validate_required([:name, :range])\n  end\nend\n\niex\u003e alias MyApp.Table\n\niex\u003e range = Date.range(~D[1989-09-22], ~D[2021-03-01])\n\niex\u003e cs = Table.changeset(%Table{}, %{name: \"table\", range: range})\n\niex\u003e cs.changes\n%Ecto.Changeset{\n  changes: %{\n    range: %Postgrex.Range{\n      lower: ~D[1989-09-22],\n      upper: ~D[2021-03-01],\n      lower_inclusive: true,\n      upper_inclusive: true\n    },\n    name: \"name\"\n  },\n  data: %MyApp.Table{id: nil, name: nil, range: nil},\n  params: %{\n    \"range\" =\u003e Date.range(~D[1989-09-22], ~D[2021-03-01]),\n    \"name\" =\u003e \"name\"\n  },\n  valid?: true\n}\n```\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `ectorange` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:ecto_range, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at \u003chttps://hexdocs.pm/ectorange\u003e.\n\n## Alternative libraries\n\nIf you're unhappy with the feature set`EctoRange`, there are some alternative libraries that provide similar functionality\n\n- [ecto_date_time_range](https://github.com/synchronal/ecto_date_time_range)\n- [pg_ranges](https://github.com/vforgione/pg_ranges)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavydog187%2Fecto_range","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavydog187%2Fecto_range","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavydog187%2Fecto_range/lists"}