View Source Elph.Contents (elph v0.9.1)

The Contents context. This is the main module of the elph library. It provides functions to work with contents.

Link to this section Summary

Functions

Contents that aren't shared and have no ancestor that is shared are not being used anymore. This function deletes them from the database.

Creates a specific media_content. I.e. audio_content, image_content, etc.

Deletes a Content.

Gets a single content.

Returns the list of contents without relations between them. The children arrays are empty here

Calls a function for the given content tree. If the function returns a content with children, the function will also be called for all the children.

Creates and updates a content-tree. Contents with an id will be updated, contents without an id are treated as new

This function sets all contents found within the given queryable to shared: false. This is faster then cleaning them up manually. They will then be garbage collected in the near future.

This function sets all contents with tht given ids to shared: false. This is faster then cleaning them up manually. They will then be garbage collected in the near future.

Link to this section Functions

Link to this function

cleanup_orphaned_contents()

View Source

Contents that aren't shared and have no ancestor that is shared are not being used anymore. This function deletes them from the database.

Link to this function

create_media_content(attrs)

View Source

Creates a specific media_content. I.e. audio_content, image_content, etc.

examples

Examples

iex> create_media_content(%{field: value})
{:ok, %Content{}}

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

Deletes a Content.

examples

Examples

iex> delete_content(content)
:ok

iex> delete_content(content)
{:error, reason}
Link to this function

get_content!(id, action \\ :show)

View Source

Gets a single content.

Raises Ecto.NoResultsError if the Content does not exist.

examples

Examples

iex> get_content!(123)
%Content{}

iex> get_content!(456)
** (Ecto.NoResultsError)
Link to this function

list_contents(opts \\ [])

View Source

Returns the list of contents without relations between them. The children arrays are empty here

examples

Examples

iex> list_contents()
[%Content{}, ...]

Calls a function for the given content tree. If the function returns a content with children, the function will also be called for all the children.

Creates and updates a content-tree. Contents with an id will be updated, contents without an id are treated as new

todo-examples

TODO: Examples

iex> persist_content(content, %{field: new_value})
{:ok, %Content{}}

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

This function sets all contents found within the given queryable to shared: false. This is faster then cleaning them up manually. They will then be garbage collected in the near future.

This function sets all contents with tht given ids to shared: false. This is faster then cleaning them up manually. They will then be garbage collected in the near future.