# `Cardbox.Collection`
[🔗](https://github.com/hattoriai/cardbox/blob/v0.1.0/lib/cardbox/collection.ex#L1)

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.

# `t`

```elixir
@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
}
```

# `field`

```elixir
@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`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
