This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
bdfr-browser/lib/bdfr_browser/subreddit.ex
Daniel Kempkens 38df258ce5
All checks were successful
Build / build (push) Successful in 2m42s
feat: Simulated multireddits
2023-10-02 12:59:52 +02:00

25 lines
562 B
Elixir

defmodule BdfrBrowser.Subreddit do
use Ecto.Schema
import Ecto.Query, only: [from: 2]
alias BdfrBrowser.Post
schema "subreddits" do
field :name, :string
has_many :posts, Post
end
def multiple_names(names) do
from(s in __MODULE__, where: s.name in ^names)
end
def names do
from(s in __MODULE__, select: s.name, order_by: [asc: fragment("lower(?)", s.name)])
end
def names_without(hidden) do
from(s in __MODULE__, select: s.name, where: s.name not in ^hidden, order_by: [asc: fragment("lower(?)", s.name)])
end
end