EpochtalkServer.Models.RolePermission (epochtalk_server v0.1.0)

RolePermission model, for performing actions relating to a roles permissions

Link to this section Summary

Functions

Creates a generic changeset for RolePermission model

Inserts a new RolePermission into the database

Sets all roles permissions to value: false, modified: false

Derives a single nested map of all permissions for a role

Used to update the value of a RolePermission in the database, if it exists or created it, if it doesnt

Link to this section Types

@type t() :: %EpochtalkServer.Models.RolePermission{
  __meta__: term(),
  modified: boolean() | nil,
  permission: EpochtalkServer.Models.Permission.t() | term(),
  permission_path: term(),
  role: EpochtalkServer.Models.Role.t() | term(),
  role_id: term(),
  value: boolean() | nil
}

Link to this section Functions

Link to this function

changeset(role_permission, attrs \\ %{})

@spec changeset(role_permission :: t(), attrs :: map() | nil) :: Ecto.Changeset.t()

Creates a generic changeset for RolePermission model

Link to this function

insert(role_permission)

@spec insert(role_permission_or_role_permissions :: t() | [map()]) ::
  {:ok, role :: t()}
  | {non_neg_integer(), nil | [term()]}
  | {:error, Ecto.Changeset.t()}

Inserts a new RolePermission into the database

@spec maybe_init!() :: [t()] | nil

Sets all roles permissions to value: false, modified: false

For server-side role-loading use, only runs if roles permissions table is currently empty

Link to this function

permissions_map_by_role_id(role_id)

@spec permissions_map_by_role_id(role_id :: integer()) :: map()

Derives a single nested map of all permissions for a role

Link to this function

upsert_value(roles_permissions)

@spec upsert_value(role_permissions :: [%{}]) :: {non_neg_integer(), nil | [term()]}

Used to update the value of a RolePermission in the database, if it exists or created it, if it doesnt