EDA.Entity.Changeset (EDA v0.3.0)

Copy Markdown View Source

Lightweight changeset for batching entity mutations into a single API call.

Examples

guild
|> EDA.Guild.changeset()
|> EDA.Guild.change(:name, "New Name")
|> EDA.Guild.change(:icon, icon_data)
|> EDA.Guild.apply_changeset(reason: "Rebranding")

Summary

Functions

Returns true if the changeset has any changes.

Returns the accumulated changes as a map.

Creates a new changeset for the given entity.

Puts a change into the changeset.

Types

t()

@type t() :: %EDA.Entity.Changeset{changes: map(), entity: struct(), module: module()}

Functions

changed?(changeset)

@spec changed?(t()) :: boolean()

Returns true if the changeset has any changes.

changes(changeset)

@spec changes(t()) :: map()

Returns the accumulated changes as a map.

new(entity, module)

@spec new(
  struct(),
  module()
) :: t()

Creates a new changeset for the given entity.

put(cs, key, value)

@spec put(t(), atom(), term()) :: t()

Puts a change into the changeset.