---
url: https://docs.juniper.bot/en/message-templates/types/storage/guild-index.md
description: GuildIndex data type used in JuniperBot Template Engine.
---

[Number]: /en/message-templates/types/index#literals

[String]: /en/message-templates/types/index#literals

[Boolean]: /en/message-templates/types/index#literals

[List]: /en/message-templates/types/index#lists

[Map]: /en/message-templates/types/index#maps

[DateTime]: /en/message-templates/types/index#datetime

[TwitchChannel]: /en/message-templates/types/subscriptions/twitch#twitch-channel

[TwitchStream]: /en/message-templates/types/subscriptions/twitch#twitch-stream

[TwitchGame]: /en/message-templates/types/subscriptions/twitch#twitch-game

[YouTubeChannel]: /en/message-templates/types/subscriptions/youtube#youtube-channel

[YouTubeVideo]: /en/message-templates/types/subscriptions/youtube#youtube-video

[VkWallPost]: /en/message-templates/types/subscriptions/vk#vkwallpost

[Rank]: /en/message-templates/types/discord/rank

[Guild]: /en/message-templates/types/discord/guild

[Member]: /en/message-templates/types/discord/member

[Role]: /en/message-templates/types/discord/role

[Message]: /en/message-templates/types/discord/message

[Attachment]: /en/message-templates/types/discord/attachment

[Embed]: /en/message-templates/types/discord/embed

[Activity]: /en/message-templates/types/discord/activity

[MemberVoiceState]: /en/message-templates/types/discord/member-voice-state

[MemberPrimaryGuild]: /en/message-templates/types/discord/member-primary-guild

[MenuBuilder]: /en/message-templates/types/discord/menu-builder

[UserFlag]: /en/message-templates/types/discord/user-flag

[Permission]: /en/message-templates/types/discord/permission

[Category]: /en/message-templates/types/discord/category

[TextChannel]: /en/message-templates/types/discord/text-channel

[VoiceChannel]: /en/message-templates/types/discord/voice-channel

[NewsChannel]: /en/message-templates/types/discord/news-channel

[StageChannel]: /en/message-templates/types/discord/stage-channel

[ForumChannel]: /en/message-templates/types/discord/forum-channel

[MediaChannel]: /en/message-templates/types/discord/media-channel

[ThreadChannel]: /en/message-templates/types/discord/thread-channel

[Page]: /en/message-templates/types/storage/page

[GuildIndex]: /en/message-templates/types/storage/guild-index

[GuildIndexEntry]: /en/message-templates/types/storage/guild-index-entry

[GuildIndexes]: /en/message-templates/types/storage/guild-indexes

[MemberAttribute]: /en/message-templates/types/storage/member-attribute

[MemberAttributes]: /en/message-templates/types/storage/member-attributes

[Arguments]: /en/message-templates/types/custom-commands/arguments

[Parameters]: /en/message-templates/types/custom-commands/parameters

[Component]: /en/message-templates/types/custom-commands/component

[Modal]: /en/message-templates/types/custom-commands/modal

# GuildIndex

This data type describes specific guild's index. Guild Indexes can be used to store a set of sorted data.

::: info
For more information about guild indexes and how to use them, check
[Guild Indexes](../../persistence/guild-indexes) article.
:::

## Properties { #properties }

This is dynamic type properties of which are automatically generated based on index [entry](guild-index-entry) keys if
they are valid identifiers.

::: warning
You can only access 2 index entries in single message template, e.g. two entries of a single index or one entry per two
different indexes.
:::

## Methods { #methods }

### `get(Key)` { #method-get .template-method }

::: tabs

\== Description | mdi-text

Returns or creates an entry by its key.

**Returns:** \[GuildIndexEntry]

\== Parameters | mdi-code-parentheses

| Parameter | Type      | Description                    |
|:----------|:----------|:-------------------------------|
| `Key`     | \[String]  | Entry key up to 255 characters |

\== Examples | mdi-code-block-braces

```template
{% set entry = guild.getIndex('myIndex').get('entryKey') %}
```

```template
{% set entry = guild.indexes.myIndex.entryKey %}
```

:::

### `update(Entries)` { #method-update .template-method }

::: tabs

\== Description | mdi-text

Batch updates multiple entries at once (up to 2).

\== Parameters | mdi-code-parentheses

| Parameter | Type                      | Description                                                                                  |
|:----------|:--------------------------|:---------------------------------------------------------------------------------------------|
| `Entries` | \[Map]<\[String], \[Number]> | Keys are entry keys up to 255 characters;Values are their values. |

\== Examples | mdi-code-block-braces

```template
{% do guild.getIndex('myIndex').update({ key1: 1, key2: 2 }) %}
```

```template
{% do guild.indexes.myIndex.update({ key1: 1, key2: 2 }) %}
```

:::

### `getPageOf(Number, Size, Sort)` { #method-getpageof .template-method }

::: tabs

\== Description | mdi-text

Returns a page of index entries by page number and size with specified sorting direction.

**Returns:** \[Page]<\[GuildIndexEntry]>

\== Parameters | mdi-code-parentheses

| Parameter | Type     | Description                                                                                   |
|:----------|:---------|:----------------------------------------------------------------------------------------------|
| `Number`  | \[Number] | Page number (count starts from 0)                                                             |
| `Size`    | \[Number] | Page size (up to 25 entries)                                                                  |
| `Sort`    | \[String] | Entry values sort direction:`'DESC'` — descending;`'ASC'` or any other — ascending. |

\== Examples | mdi-code-block-braces

```template
{% set page = guild.getIndex('myIndex').getPageOf(0, 10, 'DESC') %}
```

```template
{% set page = guild.indexes.myIndex.getPageOf(0, 10, 'DESC') %}
```

:::

### `clearAll()` { #method-clearall .template-method }

::: tabs

\== Description | mdi-text

Clears all entries of this index.

\== Examples | mdi-code-block-braces

```template
{% do guild.getIndex('myIndex').clearAll() %}
```

```template
{% do guild.indexes.myIndex.clearAll() %}
```

:::
