View Source Tags_Multi_Tenant (Tags_Multi_Tenant v0.1.0)

Documentation for Tags_Multi_Tenant. Tags_Multi_Tenant allows you to manage tags associated to your records.

Please read README.md to get more info about how to use that package.

Link to this section Summary

Functions

Get a persisted struct and inserts a new tag associated to this struct for a specific context.

Get a persisted struct and removes the tag association for a specific context.

Rename the tag name by a new one. This actions has effect only in the context specificied.

It searchs the associated tags for a specific context.

It works exactly like tag_list but return a queryable

Given a tag, module and context ('tag' by default), will find all the module resources associated to the given tag.

The same than tagged_with/3 but returns the query instead of db results.

Link to this section Types

Specs

context() :: String.t()

Specs

opts() :: list()

Specs

tag() :: String.t()

Specs

tag_list() :: list()

Specs

taggable() :: module() | struct()

Specs

tags() :: String.t() | list()

Link to this section Functions

Link to this function

add(struct, tags, context \\ "tags", opts \\ [])

View Source

Specs

add(struct(), tags(), context(), opts()) :: struct()

Get a persisted struct and inserts a new tag associated to this struct for a specific context.

You can pass a tag or a list of tags.

In case the tag would be duplicated nothing will happen.

It returns the struct with a new entry for the given context.

Link to this function

remove(struct, tag, context \\ "tags", opts \\ [])

View Source

Specs

remove(struct(), tag(), context(), opts()) :: struct()

Get a persisted struct and removes the tag association for a specific context.

In case the association doesn't exist nothing will happen.

In the same way that add/3 it returns a struct

Link to this function

rename(struct, old_tag_name, new_tag_name, context, opts \\ [])

View Source

Specs

rename(struct(), tag(), tag(), context(), opts()) :: nil | struct()

Rename the tag name by a new one. This actions has effect only in the context specificied.

If the old_tag does not exist return nil.

Link to this function

tag_list(taggable, context \\ "tags", opts \\ [])

View Source

Specs

tag_list(taggable(), context(), opts()) :: tag_list()

It searchs the associated tags for a specific context.

You can pass as first argument an struct or a module (phoenix model)

  • With a struct: it returns the list of tags associated to that struct and context.
  • With a module: it returns all the tags associated to one module and context.
Link to this function

tag_list_queryable(taggable, context \\ "tags")

View Source

Specs

tag_list_queryable(taggable(), context()) :: Ecto.Queryable.t()

It works exactly like tag_list but return a queryable

You can pass as first argument an struct or a module (phoenix model)

  • With a struct: it returns the list of tags associated to that struct and context.
  • With a module: it returns all the tags associated to one module and context.
Link to this function

tagged_with(tags, model, context \\ "tags", opts \\ [])

View Source

Specs

tagged_with(tags(), module(), context(), opts()) :: list()

Given a tag, module and context ('tag' by default), will find all the module resources associated to the given tag.

You can pass a simple tag or a list of tags.

Link to this function

tagged_with_query(query, tags, context \\ "tags")

View Source

The same than tagged_with/3 but returns the query instead of db results.

The purpose of this function is allow you to include it in your filter flow or perform actions like paginate the results.