View Source Bonfire.Social.Bookmarks (Bonfire v0.9.10-classic-beta.169)

Mutate or query bookmarks (similar to likes but only visible to the creator of the bookmark)

Bookmarks are implemented on top of the Bonfire.Data.Edges.Edge schema (see Bonfire.Social.Edges for shared functions)

Summary

Functions

Bookmarks an object for a user.

Checks if a user has bookmarked an object.

Retrieves bookmark(er)s for an object.

Retrieves bookmarked objects by a subject.

Counts bookmarks based on filters and options.

Retrieves a bookmark by subject and object.

Retrieves a bookmark edge, raising an error if not found.

Lists bookmarks by a specific user.

Lists the current user's bookmarks.

Lists bookmark(er)s of a specific object or objects.

Removes a bookmark from an object for a user, if one exists

Functions

Link to this function

bookmark(bookmarker, bookmarked, opts \\ [])

View Source

Bookmarks an object for a user.

Examples

iex> Bonfire.Social.Bookmarks.bookmark(user, object)
{:ok, %Bonfire.Data.Social.Bookmark{}}
Link to this function

bookmarked?(user, object)

View Source

Checks if a user has bookmarked an object.

Examples

iex> Bonfire.Social.Bookmarks.bookmarked?(user, object)
true
Link to this function

by_bookmarked(object, opts \\ [])

View Source

Retrieves bookmark(er)s for an object.

Examples

iex> Bonfire.Social.Bookmarks.by_bookmarked(object)
[%Bonfire.Data.Social.Bookmark{}, ...]
Link to this function

by_bookmarker(subject, opts \\ [])

View Source

Retrieves bookmarked objects by a subject.

Examples

iex> Bonfire.Social.Bookmarks.by_bookmarker(user)
[%Bonfire.Data.Social.Bookmark{}, ...]
Link to this function

count(filters \\ [], opts \\ [])

View Source

Counts bookmarks based on filters and options.

Examples

iex> Bonfire.Social.Bookmarks.count([subject: user_id], [])
5

iex> Bonfire.Social.Bookmarks.count(user, object)
1

iex> Bonfire.Social.Bookmarks.count(object, [])
10
Link to this function

get(subject, object, opts \\ [])

View Source

Retrieves a bookmark by subject and object.

Examples

iex> Bonfire.Social.Bookmarks.get(user, object)
{:ok, %Bonfire.Data.Social.Bookmark{}}
Link to this function

get!(subject, object, opts \\ [])

View Source

Retrieves a bookmark edge, raising an error if not found.

Link to this function

list_by(by_user, opts \\ [])

View Source

Lists bookmarks by a specific user.

Examples

iex> Bonfire.Social.Bookmarks.list_by(user_id, current_user: me)
[%Bonfire.Data.Social.Bookmark{}, ...]

Lists the current user's bookmarks.

Examples

iex> Bonfire.Social.Bookmarks.list_my(current_user: me)
[%Bonfire.Data.Social.Bookmark{}, ...]
Link to this function

list_of(object, opts \\ [])

View Source

Lists bookmark(er)s of a specific object or objects.

Examples

iex> Bonfire.Social.Bookmarks.list_of(object_id)
[%Bonfire.Data.Social.Bookmark{}, ...]

Callback implementation for Bonfire.Common.ContextModule.query_module/0.

Callback implementation for Bonfire.Common.ContextModule.schema_module/0.

Link to this function

unbookmark(bookmarker, object, opts \\ [])

View Source

Removes a bookmark from an object for a user, if one exists

Examples

iex> Bonfire.Social.Bookmarks.unbookmark(user, object)
:ok