Back.Posts (CAMI-Back v0.1.0)

View Source

The Posts context.

Summary

Functions

Returns an %Ecto.Changeset{} for tracking post changes.

Creates a post.

Deletes a post.

Gets a single post.

Returns the list of post.

Updates a post.

Functions

change_post(post, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking post changes.

Examples

iex> change_post(post)
%Ecto.Changeset{data: %Post{}}

create_post(attrs \\ %{})

Creates a post.

Examples

iex> create_post(%{field: value})
{:ok, %Post{}}

iex> create_post(%{field: bad_value})
{:error, %Ecto.Changeset{}}

delete_post(post)

Deletes a post.

Examples

iex> delete_post(post)
{:ok, %Post{}}

iex> delete_post(post)
{:error, %Ecto.Changeset{}}

get_post!(id)

Gets a single post.

Raises Ecto.NoResultsError if the Post does not exist.

Examples

iex> get_post!(123)
%Post{}

iex> get_post!(456)
** (Ecto.NoResultsError)

list_post()

Returns the list of post.

Examples

iex> list_post()
[%Post{}, ...]

update_post(post, attrs)

Updates a post.

Examples

iex> update_post(post, %{field: new_value})
{:ok, %Post{}}

iex> update_post(post, %{field: bad_value})
{:error, %Ecto.Changeset{}}