Dymo v0.1.2 Dymo.Tag View Source

This module provides functionality dedicated to handling tag data.

Link to this section Summary

Types

t()

The Dymo.Tag.t() schema defines simple tags identified by a unique label

Functions

Makes a changeset suited to manipulate the Dymo.Tag model

This function gets an existing tag using its label. If the tag doesn’t exit, it is atomically created. It could be described as a “singleton” helper

Link to this section Types

Link to this type t() View Source
t() :: %Dymo.Tag{
  __meta__: term(),
  id: term(),
  inserted_at: term(),
  label: term(),
  updated_at: term()
}

The Dymo.Tag.t() schema defines simple tags identified by a unique label.

Link to this section Functions

Makes a changeset suited to manipulate the Dymo.Tag model.

Link to this function find_or_create!(labels) View Source
find_or_create!(String.t() | [String.t()]) :: t()

This function gets an existing tag using its label. If the tag doesn’t exit, it is atomically created. It could be described as a “singleton” helper.

Examples

iex> %{id: id1a} = Tag.find_or_create!("novel")
iex> [%{id: id2a}, %{id: id3a}] = Tag.find_or_create!(["article", "book"])
iex> [%{id: id1b}, %{id: id2b}, %{id: id3b}] = Tag.find_or_create!(["novel", "article", "book"])
iex> {id1a, id2a, id3a} == {id1b, id2b, id3b}
true