Cardbox.Collection (Cardbox v0.1.0)

Copy Markdown View Source

A collection: records of one kind, with the same fields.

A collection belongs to something of your app, its owner: a workspace, an account, a page. owner_type and owner_id say which, as text, so a collection belongs to a record of any table and id of any type:

MyApp.Cardbox.create_collection(%{name: "Reading list", owner: {"workspace", 42}})

fields are its fields in their order (Cardbox.Field), loaded with it. Every function of use Cardbox that changes the fields returns the collection as it is after.

Summary

Functions

The field of a collection with this key, or with this name (without case), or nil. A field struct is taken as itself.

The field that names a record, as a relation shows it: the first text field, or nil.

Types

t()

@type t() :: %Cardbox.Collection{
  __meta__: term(),
  description: String.t() | nil,
  fields: [Cardbox.Field.t()] | Ecto.Association.NotLoaded.t(),
  icon: String.t() | nil,
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  name: String.t(),
  owner_id: String.t() | nil,
  owner_type: String.t() | nil,
  updated_at: DateTime.t() | nil
}

Functions

field(collection, field)

@spec field(t(), term()) :: Cardbox.Field.t() | nil

The field of a collection with this key, or with this name (without case), or nil. A field struct is taken as itself.

title_field(collection)

@spec title_field(t()) :: Cardbox.Field.t() | nil

The field that names a record, as a relation shows it: the first text field, or nil.