# `TagsMultiTenant`
[🔗](https://github.com/augustwenty/tags_multi_tenant/blob/main/lib/tags_multi_tenant.ex#L1)

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

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

# `context`

```elixir
@type context() :: String.t()
```

# `opts`

```elixir
@type opts() :: Keyword.t()
```

# `tag`

```elixir
@type tag() :: String.t()
```

# `tag_list`

```elixir
@type tag_list() :: list()
```

# `taggable`

```elixir
@type taggable() :: module() | struct()
```

# `tags`

```elixir
@type tags() :: String.t() | list()
```

# `add`

```elixir
@spec 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.

# `remove`

```elixir
@spec 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

# `rename`

```elixir
@spec 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.

# `tag_list`

```elixir
@spec 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.

# `tag_list_queryable`

```elixir
@spec 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.

# `tagged_with`

```elixir
@spec 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.

# `tagged_with_query`

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
