mirror of
https://github.com/mgerb/classic-wow-forums
synced 2026-01-11 17:42:48 +00:00
lots of things done: thread - reply - category - seeds
This commit is contained in:
24
lib/myapp/data/category.ex
Normal file
24
lib/myapp/data/category.ex
Normal file
@@ -0,0 +1,24 @@
|
||||
defmodule MyApp.Data.Category do
|
||||
use Ecto.Schema
|
||||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
alias MyApp.Repo
|
||||
alias MyApp.Data
|
||||
|
||||
@derive {Poison.Encoder, except: [:__meta__]}
|
||||
schema "category" do
|
||||
field :category, :string
|
||||
field :title, :string
|
||||
end
|
||||
|
||||
def changeset(category, params \\ %{}) do
|
||||
category
|
||||
|> cast(params, [:category, :title])
|
||||
|> validate_required([:category, :title])
|
||||
end
|
||||
|
||||
def get_categories() do
|
||||
Repo.all(Data.Category)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user