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)
def names do
from(s in __MODULE__, select: s.name, order_by: [asc: fragment("lower(?)", s.name)])
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)])