sloanelybutsurely.com/lib/cms/posts.ex
2025-02-22 12:35:49 -05:00

25 lines
383 B
Elixir

defmodule CMS.Posts do
@moduledoc false
alias CMS.Posts.Post
alias CMS.Repo
def create_post(attrs) do
%Post{}
|> Post.changeset(attrs)
|> Repo.insert()
end
def update_post(post, attrs) do
post
|> Post.changeset(attrs)
|> Repo.update()
end
def get_post!(id) do
Repo.get!(Post, id)
end
def list_posts do
Repo.all(Post)
end
end