Mirage.Notes (mirage v0.76.0)

The Notes context.

The Note is the primary piece of content. It always is part of a Mirage.Lists.List and has multiple Mirage.Tags.Tags.

Link to this section Summary

Functions

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

Creates a note.

Creates a note and runs the note hooks

Deletes a note.

Gets a single note.

Returns the list of notes.

Returns the list of notes sorted by MirageWeb.Live.NoteListParams

Returns the list of published notes.

Preloads a note with all defined preloads.

Publishes a note by setting published_at to utc_now

Returns list of notes containg the given query_string

Unpublishes a note by setting published_at to nil

Updates a note.

Updates a note and runs the note hooks.

Link to this section Functions

Link to this function

change_note(note, attrs \\ %{})

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

Examples

iex> change_note(note)
%Ecto.Changeset{data: %Note{}}
Link to this function

create_note(attrs \\ %{})

Creates a note.

Examples

iex> create_note(%{field: value})
{:ok, %Note{}}

iex> create_note(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_note_with_hooks(attrs \\ %{})

Creates a note and runs the note hooks

Link to this function

delete_note(note)

Deletes a note.

Examples

iex> delete_note(note)
{:ok, %Note{}}

iex> delete_note(note)
{:error, %Ecto.Changeset{}}

Gets a single note.

Raises Ecto.NoResultsError if the Note does not exist.

Examples

iex> get_note!(123)
%Note{}

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

Returns the list of notes.

Examples

iex> list_notes()
[%Note{}, ...]
Link to this function

list_notes(opts)

Returns the list of notes sorted by MirageWeb.Live.NoteListParams

Internal use only

Link to this function

list_published_notes()

Returns the list of published notes.

Examples

iex> list_notes()
[%Note{}, ...]
Link to this function

preload_note(note)

Preloads a note with all defined preloads.

Examples

iex> preload_note(note)
%Note{}
Link to this function

publish_note(note)

Publishes a note by setting published_at to utc_now

Examples

iex> publish_note(note)
{:ok, %Note{}}
Link to this function

search_notes(query_string)

Returns list of notes containg the given query_string

Examplex

iex> search_notes("foo")
[%Note{}, ...]
Link to this function

unpublish_note(note)

Unpublishes a note by setting published_at to nil

Examples

iex> publish_note(note)
{:ok, %Note{}}
Link to this function

update_note(note, attrs)

Updates a note.

Examples

iex> update_note(note, %{field: new_value})
{:ok, %Note{}}

iex> update_note(note, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

update_note_with_hooks(note, attrs)

Updates a note and runs the note hooks.