Etcher.Storage.Default (etcher v0.1.0)

Copy Markdown View Source

Default Etcher.Storage implementation backed by the bundled etcher_annotations table.

Reads the consumer's Repo from config :etcher, repo: MyApp.Repo. If :etcher, :repo is missing, create/1 / update/2 / delete/1 return {:error, :no_repo_configured} rather than crashing.

Consumers with custom schemas should implement their own Etcher.Storage adapter instead of using this one.

Summary

Functions

Insert a new annotation row. Returns {:ok, annotation} on success, {:error, :no_repo_configured} when config :etcher, :repo isn't set, or {:error, changeset} on validation failure.

Delete an annotation by UUID. Returns :ok, {:error, :no_repo_configured}, {:error, :not_found}, or {:error, changeset} if the delete fails.

List annotations for a target, ordered by position ascending then inserted_at ascending. Returns [] if no Repo is configured.

Update an annotation by UUID. Returns {:ok, annotation} on success, {:error, :no_repo_configured}, {:error, :not_found}, or {:error, changeset} on validation failure.

Functions

create(attrs)

Insert a new annotation row. Returns {:ok, annotation} on success, {:error, :no_repo_configured} when config :etcher, :repo isn't set, or {:error, changeset} on validation failure.

delete(uuid)

Delete an annotation by UUID. Returns :ok, {:error, :no_repo_configured}, {:error, :not_found}, or {:error, changeset} if the delete fails.

list_for(target_type, target_uuid)

List annotations for a target, ordered by position ascending then inserted_at ascending. Returns [] if no Repo is configured.

update(uuid, attrs)

Update an annotation by UUID. Returns {:ok, annotation} on success, {:error, :no_repo_configured}, {:error, :not_found}, or {:error, changeset} on validation failure.