config_db search methods
This commit is contained in:
parent
7fd4f4908b
commit
a02eb88396
2 changed files with 24 additions and 18 deletions
|
|
@ -6,7 +6,7 @@ defmodule Pleroma.ConfigDB do
|
|||
use Ecto.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query, only: [select: 3]
|
||||
import Ecto.Query, only: [select: 3, from: 2]
|
||||
import Pleroma.Web.Gettext
|
||||
|
||||
alias __MODULE__
|
||||
|
|
@ -41,6 +41,16 @@ defmodule Pleroma.ConfigDB do
|
|||
end)
|
||||
end
|
||||
|
||||
@spec get_all_by_group(atom() | String.t()) :: [t()]
|
||||
def get_all_by_group(group) do
|
||||
from(c in ConfigDB, where: c.group == ^group) |> Repo.all()
|
||||
end
|
||||
|
||||
@spec get_all_by_group_and_key(atom() | String.t(), atom() | String.t()) :: [t()]
|
||||
def get_all_by_group_and_key(group, key) do
|
||||
from(c in ConfigDB, where: c.group == ^group and c.key == ^key) |> Repo.all()
|
||||
end
|
||||
|
||||
@spec get_by_params(map()) :: ConfigDB.t() | nil
|
||||
def get_by_params(params), do: Repo.get_by(ConfigDB, params)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue