expand documention for ecto usage

This commit is contained in:
Sloane Perrault 2023-07-16 10:26:59 -04:00
parent 9db8183417
commit 6158128e61
No known key found for this signature in database

View file

@ -32,7 +32,23 @@ defmodule MyApp.Accounts.User do
use Ecto.Schema
@primary_key {:id, TypeID, autogenerate: true, prefix: "acct", type: :binary_id}
@foreign_key_type TypeID
# ...
end
```
### Underlying types
`TypeID`s can be stored as either `:string` or `:binary_id`. `:string` will
store the entire TypeID including the prefix. `:binary_id` stores only the
UUID portion and requires a `:uuid` or `:binary` column.
#### Default type
The type used can be set globally in the application config.
```elixir
config :typeid_elixir,
default_type: :binary_id
```