Ecto.ParameterizedType that stores a Tempo expression whole in a
SQLite TEXT column.
SQLite has no range type. The column holds the JSON document
Tempo.SQL.SQLite.Document writes: the expression's ISO 8601 text,
read back as it was written, beside the integer bounds of the time it
covers and of each of its spans, which Tempo.Ecto.SQLite.QueryAPI
queries. It takes any expression with ISO 8601 text and a place on
the time line: a value, an interval, a set, a recurrence.
Usage
schema "meetings" do
field :window, Tempo.Ecto.SQLite.TempoRange
field :opening_hours, Tempo.Ecto.SQLite.TempoRange, frame: :floating
endand in the migration:
import Tempo.SQL.SQLite.Migration
create table(:meetings) do
add_tempo_range :window
end
create_tempo_range_index :meetings, :windowOptions
:frame—:utc(the default) for values in a zone or at a time shift, stored as seconds since the Unix epoch at UTC, or:floatingfor values with neither, stored as seconds on the wall clock. A value of the other frame is refused bycast/2, as a changeset error that names the frame to declare, and bydump/3.
Precision
The bounds are whole seconds, rounded outward, so a query of a span shorter than a second may find its neighbours. The expression itself is kept as written and loads back exactly.
Summary
Functions
Builds the parameterized-type tuple for use outside a schema.
Functions
@spec cast_type(keyword()) :: Ecto.Type.t()
Builds the parameterized-type tuple for use outside a schema.
Arguments
optionsis a keyword list of options.
Options
:frameis:utc(the default) or:floating.
Returns
- A
Ecto.ParameterizedType.opts/0tuple.
Examples
iex> Tempo.Ecto.SQLite.TempoRange.cast_type()
{:parameterized, {Tempo.Ecto.SQLite.TempoRange, %{frame: :utc}}}
iex> Tempo.Ecto.SQLite.TempoRange.cast_type(frame: :floating)
{:parameterized, {Tempo.Ecto.SQLite.TempoRange, %{frame: :floating}}}