{"id":16389464,"url":"https://github.com/qqwy/elixir-revisionair","last_synced_at":"2025-12-12T00:25:32.721Z","repository":{"id":41690294,"uuid":"89172418","full_name":"Qqwy/elixir-revisionair","owner":"Qqwy","description":"Keep track of your data structure's revisions, persistence layer agnostic.","archived":false,"fork":false,"pushed_at":"2023-03-30T07:58:37.000Z","size":39,"stargazers_count":28,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-14T20:20:48.017Z","etag":null,"topics":["elixir-lang","elixir-library","revision"],"latest_commit_sha":null,"homepage":null,"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/Qqwy.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}},"created_at":"2017-04-23T21:03:59.000Z","updated_at":"2023-12-25T13:50:22.000Z","dependencies_parsed_at":"2023-07-12T17:01:55.038Z","dependency_job_id":null,"html_url":"https://github.com/Qqwy/elixir-revisionair","commit_stats":null,"previous_names":["qqwy/elixir_revisionair"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qqwy%2Felixir-revisionair","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qqwy%2Felixir-revisionair/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qqwy%2Felixir-revisionair/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qqwy%2Felixir-revisionair/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Qqwy","download_url":"https://codeload.github.com/Qqwy/elixir-revisionair/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221811386,"owners_count":16884305,"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":["elixir-lang","elixir-library","revision"],"created_at":"2024-10-11T04:33:08.734Z","updated_at":"2025-12-12T00:25:32.677Z","avatar_url":"https://github.com/Qqwy.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Revisionair\n\n[![Hex.pm](https://img.shields.io/hexpm/v/revisionair.svg)](https://hex.pm/packages/revisionair)\n\nRevisionair is a small Elixir library that allows you to create revisions, or versioning, of your data structures.\nEach time a data structure is updated, you can store the new version. Revisionair will keep track of the versions you have stored.\n\nRevisionair is completely persistence-layer agnostic, meaning that regardless of if you use Ecto, Mnesia, Flat files, a simple ephemeral Agent,\nor a complex sharded database setup with your toaster as extra redundancy,\nyou can use it with Revisionair, by simply implementing the `Revisionair.Storage` behaviour.\n\n\n## Installation\n\nRevisionair is [available in Hex](https://hex.pm/docs/publish). The package can be installed\nby adding `revisionair` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:revisionair, \"~\u003e 0.13.0\"}]\nend\n```\n\n\n## Super Simple Usage\n\n1. Whenever a data structure you care about changes, besides storing this latest revision at its primary location,\nyou also store it using Revisionair, using `Revisionair.store_revision(my_data_structure)`.\n2. If you find out you liked an old version better, you can find it again by using `Revisionair.list_revisions(my_current_data_structure)`\n\n## Configurable\n\nThe lower-arity versions of Revisionair expect that you use structs that contain an `:id` field: The `:__struct__` key \nis used to differentiate between different kinds of data (i.e. data types) that are stored, while the `:id` field is used\nto differentiate between different entities of this data type.\n\nHowever, this is fully configurable. Revisionair's functions can be called with custom `item_type`s and `item_id` fields,\nand when you pass (arity-1) functions as these arguments, they are called on the passed structure. So this also works:\n\n```elixir\n%Car{uuid: \"14dac99c-5dde-4301-846b-3d1fa21171cc\", color: \"black\", number_of_wheels: 4}\n|\u003e Revisionair.store_revision(Vehicle, \u0026(\u00261.uuid))\n```\n\nwhich might both be useful if you do not use an `:id` field, or if you have structs whose \n`__struct__` type might change.\n\n\n## Storage\n\nThe persistence layer that Revisionair uses is fully configurable.\n\nWhich Revisionair.Storage implementation you use can be configured app-wide using the\n`config :revisionair, storage: Module.That.Implements.Revisionair.Storage` configuration setting.\n\nWhen you want to override this setting, or have more complicated persistence needs (multiple different kinds of persistence in the same application?),\nyou can pass `storage: Module.That.Implements.Revisionair.Storage` as option to all functions in the `Revolutionair` module:\n\n```elixir\nRevisionair.store_revision(my_structure, [storage: Revisionair.Storage.Agent])\n# or:\nRevisionair.store_revision(my_car, Vehicle, my_car.id, [storage: Revisionair.Storage.Agent])\n# or:\nRevisionair.store_revision(my_car, Vehicle, my_car.id, %{editor: current_user}, [storage: Revisionair.Storage.Agent])\n```\n\nRevisionair ships with a very simple `Agent` layer that is used for testing.\n\nFor your practical applications, some other storage layer might be more appropriate. Check for instance [revisionair_ecto](https://hex.pm/packages/revisionair_ecto) for an Ecto-based persistence layer.\n\nOther packages might be made by me or other people, that combine Revisionair with any of the\ndatabases and other persistence layers out there. They will be listed here.\n\nOf course, writing your own `Revisionair.Storage` implementation is very simple, as the behaviour only requires you to implement three functions.\n\n\n## Metadata\n\nIf you want to store extra data, such as the time at which the revision took place, or who made the new revision,\nyou can do so by using the `metadata` argument when using `store_revision`. \n\nThis metadata is returned when `list_revisions` or `newest_revision` is called at a later time.\n\nWhat information you store in here is completely up to you (but it is expected to be a map).\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 [https://hexdocs.pm/revisionair](https://hexdocs.pm/revisionair).\n\n\n\n## Changelog\n\n- 0.13.4 Updates version of dev-dependency `ex_doc` which has not been updated for a long time.\n- 0.13.3 Fixing return value of `delete_all_revisions`. Thank you, @mindreframer!\n- 0.13 Renaming `structure_type` and `unique_identifier` parameter names to `item_type` and `item_id` respectively, for brevity/readability.\n- 0.12 Possibility of passing extra options to the storage layer, under the `storage_options:` key.\n- 0.11 Rename `persistence:` option to `storage:`, as this follows the naming of `Revisionair.Storage`.\n- 0.10 Adds `Revisionair.get_revision`, and all revisions are now required to store a `:revision` field, that allows you to track which exact revision some other part of your app is talking about.\n- 0.9.2 Some small bugfixes and improved documentation.\n- 0.9 First publicly released version. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqqwy%2Felixir-revisionair","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqqwy%2Felixir-revisionair","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqqwy%2Felixir-revisionair/lists"}