View Source PaperTrail.VersionQueries (paper_trail v1.0.0)

Link to this section Summary

Functions

Gets the current model record/struct of a version

Gets the last version of a record.

Gets all the versions of a record.

Gets all the versions of a record given a module and its id

Link to this section Functions

Link to this function

get_current_model(version)

View Source
@spec get_current_model(version :: PaperTrail.Version.t()) :: Ecto.Schema.t() | nil

Gets the current model record/struct of a version

@spec get_version(record :: Ecto.Schema.t()) :: PaperTrail.Version.t() | nil

Gets the last version of a record.

A list of options is optional, so you can set for example the :prefix of the query, wich allows you to change between different tenants.

Usage examples:

iex(1)> PaperTrail.VersionQueries.get_version(record, id) iex(1)> PaperTrail.VersionQueries.get_version(record, [prefix: "tenant_id"]) iex(1)> PaperTrail.VersionQueries.get_version(ModelName, id) iex(1)> PaperTrail.VersionQueries.get_version(ModelName, id, [prefix: "tenant_id"])

@spec get_version(model :: module(), id :: pos_integer()) ::
  PaperTrail.Version.t() | nil
@spec get_version(record :: Ecto.Schema.t(), options :: keyword() | []) ::
  PaperTrail.Version.t() | nil
Link to this function

get_version(model, id, options)

View Source
@spec get_version(model :: module(), id :: pos_integer(), options :: keyword() | []) ::
  PaperTrail.Version.t() | nil
@spec get_versions(record :: Ecto.Schema.t()) :: [PaperTrail.Version.t()]

Gets all the versions of a record.

A list of options is optional, so you can set for example the :prefix of the query, wich allows you to change between different tenants.

Usage examples:

iex(1)> PaperTrail.VersionQueries.get_versions(record) iex(1)> PaperTrail.VersionQueries.get_versions(record, [prefix: "tenant_id"]) iex(1)> PaperTrail.VersionQueries.get_versions(ModelName, id) iex(1)> PaperTrail.VersionQueries.get_versions(ModelName, id, [prefix: "tenant_id"])

@spec get_versions(model :: module(), id :: pos_integer()) :: [PaperTrail.Version.t()]
@spec get_versions(record :: Ecto.Schema.t(), options :: keyword() | []) :: [
  PaperTrail.Version.t()
]

Gets all the versions of a record given a module and its id

Link to this function

get_versions(model, id, options)

View Source
@spec get_versions(model :: module(), id :: pos_integer(), options :: keyword() | []) ::
  [
    PaperTrail.Version.t()
  ]