Files
firezone/elixir/apps/domain/lib/domain.ex
Andrew Dryga f3c8c734ab feat(portal): Filtering, Fulltext Search, Pagination, Preloads (#3751)
On the domain side this PR extends `Domain.Repo` with filtering,
pagination, and ordering, along with some convention changes are
removing the code that is not needed since we have the filtering now.
This required to touch pretty much all contexts and code, but I went
through all public functions and added missing tests to make sure
nothing will be broken.

On the web side I've introduced a `<.live_table />` which is as close as
possible to being a drop-in replacement for the regular `<.table />`
(but requires to structure the LiveView module differently due to
assigns anyways). I've updated all the listing tables to use it.
2024-03-16 13:27:48 -06:00

44 lines
897 B
Elixir

defmodule Domain do
@moduledoc """
This module provides a common interface for all the domain modules,
making sure our code structure is consistent and predictable.
"""
def schema do
quote do
use Ecto.Schema
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
@timestamps_opts [type: :utc_datetime_usec]
@type id :: binary()
end
end
def changeset do
quote do
import Ecto.Changeset
import Domain.Repo.Changeset
import Domain.Repo, only: [valid_uuid?: 1]
end
end
def query do
quote do
import Ecto.Query
import Domain.Repo.Query
@behaviour Domain.Repo.Query
end
end
@doc """
When used, dispatch to the appropriate schema/context/changeset/query/etc.
"""
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
end