A user's preferences for a view — which columns a table shows and in
what order, and whatever else the view's owner keeps (a sort, filters) —
one JSON object per (user, key).
key names the view and is namespaced by its owner: "users",
"website_access.attempts", "catalogue.detail_items",
"crm.role.<uuid>". Each top-level field of the object is written whole:
put/3 patches the fields it is given with prefs || changes inside the
upsert, so two tabs changing different fields both keep their change,
and nothing is rebuilt from a copy of the user a page happens to hold.
delete_fields/3 takes a field back out — which is what "reset" means:
the view goes back to following its default.
PhoenixKitWeb.TableColumns is the table-columns layer on top; core
gives meaning only to the "columns" field.
A user is a %{uuid: _} or a uuid; nil (nobody signed in) reads as no
preferences and writes {:error, :no_user}. Nothing here raises: a read
that fails is no preferences, a write that fails answers {:error, _}.
Summary
Functions
Takes fields out of the user's preferences for key, so the view
follows its default for them again. Answers the preferences as they now
are (%{} when the user had none).
Deletes every user's preferences for key — for a view that no longer exists.
The user's preferences for view key — %{} when they have none.
Sets the given top-level fields of the user's preferences for key,
leaving the others as stored. Answers the preferences as they now are.
Types
Functions
Takes fields out of the user's preferences for key, so the view
follows its default for them again. Answers the preferences as they now
are (%{} when the user had none).
Deletes every user's preferences for key — for a view that no longer exists.
The user's preferences for view key — %{} when they have none.
Sets the given top-level fields of the user's preferences for key,
leaving the others as stored. Answers the preferences as they now are.