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

A record of a collection: its values, by field key, in `data`.

    %Cardbox.Record{id: 7, data: %{"title" => "Dune", "status" => "reading", "rating" => 5}}

`data` holds the values as they are kept (`Cardbox.Type`): a day as text,
a choice as its id, no key for an empty value. `get/3` reads a value for
Elixir, and `to_map/2` gives every value by field name, as an agent or a
JSON API takes them.

`search_text` is the words of its texts and of its choices' names,
without case and accents, that a search looks in; Cardbox writes it with
the values.

`position` is the record's place in the collection's own order (Narabe's
position keys), the order of a view with no sort. `created_by` and
`updated_by` are the ids of who made it and who changed it last.

# `t`

```elixir
@type t() :: %Cardbox.Record{
  __meta__: term(),
  collection: term(),
  collection_id: integer() | nil,
  created_by: String.t() | nil,
  data: map(),
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  position: String.t() | nil,
  search_text: String.t() | nil,
  updated_at: DateTime.t() | nil,
  updated_by: String.t() | nil
}
```

# `get`

```elixir
@spec get(t(), Cardbox.Collection.t(), term()) :: term()
```

The value of a field of the record, read for Elixir (`Cardbox.Type.load/2`).
`field` is a field, its key or its name.

# `to_map`

```elixir
@spec to_map(t(), Cardbox.Collection.t(), keyword()) :: map()
```

Every value of the record, by field name (or by key, with `by: :key`),
as JSON takes them: a day as `"2026-10-25"`, a choice as its name, and
the record's `"id"`.

---

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