Skip to main content
A Collection is a group of records, called Documents, that all share a common schema. Each Document in a Collection is stored in the Database based on the fields that you define, and automatically generates a Local API, REST API, and GraphQL API used to manage your Documents. Collections can also enable Authentication, Uploads, and more. To define a Collection Config, use the collections property in your FrogBot Config:
FrogBot does not support Globals. Model singleton content as a Collection and enforce the single-document constraint in your application.

Organize collection files

Give each collection its own TitleCase file with a named export, such as export const Posts in src/collections/Posts.ts, and import it into your config by its own path. Adding a collection means creating its file and adding it to collections; there is no index.ts to update. When a collection gains hooks, access rules, or endpoints, turn its file into a folder with the same name:
Move Users.ts to Users/index.ts, then put its helpers in subfolders beside it. import { Users } from './collections/Users' resolves to either form, so the config doesn’t change. Move the file rather than copying it. If Users.ts and Users/index.ts both exist, ./collections/Users resolves to Users.ts and the folder is ignored. Match the casing of each import to its file name. ./collections/users finds Users.ts on macOS but fails with “Cannot find module” on Linux, for example in Docker or a deployment.

FrogBot collection model

Collections you configure remain ordinary FrogBot collections. Agents need chat and message stores, and pieces that create files need a files collection. You can adopt those roles into collections you own; FrogBot adds a files collection only when you mark one with file: true.

Role markers

FrogBot identifies managed collections by role, not by a required slug. Mark a collection with chat: true, message: true, or file: true; FrogBot keeps its slug and merges in the required configuration.
Mark at most one collection per role. With no marker, agents cause FrogBot to inject defaults at chats and messages. An unmarked collection already using either default slug causes a configuration error rather than implicit adoption.

Field contribution per role

Your compatible field, access, admin, and option values win during the merge. Missing base fields are appended and hooks are combined. FrogBot rejects incompatible base field types. chats.user and messages.id, messages.chat, and messages.parts are reserved and cannot be redefined.

Default collections

The default collections use soft deletion, appear under Collections in the admin panel, and scope access to the authenticated chat owner. The message ID is the AI SDK UI message ID, allowing an interrupted assistant message to be continued in place across database adapters. The chat’s user relationship resolves as follows:
  • No auth collection: FrogBot’s default users collection.
  • One auth collection: that collection, regardless of slug.
  • Multiple auth collections: the collection selected by admin.user.
See Chat persistence for request behavior and durability guarantees.

Collection config options

The following options are available on any CollectionConfig. FrogBot adds chat, message, and file to the built-in set; every other option below is part of the FrogBot configuration API. Configure connections in the root config. It’s best practice to write Collections in separate files and import them into the root config. Here is a minimal example:
Reminder: For more complex examples, see the Templates and Examples directories in the FrogBot repository.
The following options are available:

Fields

Fields define the schema of the Documents within a Collection.

Access Control

Collection Access Control determines what a user can and cannot do with any given Document within a Collection. To learn more, go to the Access Control documentation.

Hooks

Collection Hooks allow you to tie into the lifecycle of your Documents so you can execute your own logic during specific events. To learn more, go to the Hooks documentation.

Orderable

When orderable is enabled, FrogBot uses fractional indexing to efficiently manage document order. When enabled on collections, this allows you to manually drag and drop documents in the Admin Panel to reorder them, as well as programmatically set the order of documents via the Local API, REST API, or GraphQL API. Orderable can also be added to join fields.

Admin Options

The behavior of Collections within the Admin Panel can be customized to fit the needs of your application. This includes grouping or hiding their navigation links, adding custom components, selecting which fields to display in the List View, and more. To configure Admin Options for Collections, use the admin property in your Collection Config:
The following options are available:
Note: If you set useAsTitle to a relationship or join field, it will use only the ID of the related document(s) as the title. To display a specific field (i.e. title) from the related document instead, create a virtual field that extracts the desired data, and set useAsTitle to that virtual field.

Collection Views

admin.views accepts CollectionView[]. CollectionView is the exported union ListView | BoardView | CalendarView | CustomView. The array order controls the switcher and first-view fallback. A collection can have at most one list view, and it must be first. Omit views to use one default list view without a switcher.

Shared view properties

ViewPagination

ViewComponents

These shell slots are shared by list, board, calendar, and custom views. Each value uses a FrogBotComponent import path; array slots render in declaration order.

ListView

ListView components

BoardView

Board components See Collection board for grouping, loading, and drag behavior.

CalendarView

Calendar components See Collection calendar for modes, date fields, loading, and editing behavior.

CustomView

Custom Components

Collections can set Custom Components for their List and Edit Views. To override Collection Components, use the admin.components property in your Collection Config:
The following options are available: List slots belong to a type: 'list' entry in admin.views: use components.beforeView, toolbar, beforeTable, afterTable, afterView, and NoResults. To replace the collection list, use a type: 'custom' entry with component. See List View.

Edit View Options

Configure these slots under admin.components.edit. See Edit View for working component examples.
Document Views
Use admin.components.edit.views to replace a built-in document view or add a custom route or tab. See Document Views for configuration and examples. root is mutually exclusive with every built-in and custom nested document view. When root is configured, it must be the only key in views. Built-in and root view config Custom view config Document view configs do not support exact; custom path values use document-view routing. Document tab config
Important: All edit view components must be configured under admin.components.edit, not directly under admin.components.For example, use admin.components.edit.Status, not admin.components.Status.

Pagination

All Collections receive their own List View which displays a paginated list of documents that can be sorted and filtered. The pagination behavior of the List View can be customized on a per-Collection basis, and uses the same Pagination API that FrogBot provides. To configure pagination options, use pagination on a list entry in admin.views:
The following options are available:

List Searchable Fields

In the List View, there is a “search” box that allows you to quickly find a document through a simple text search. Normal search behavior includes the ID and, when defined, admin.useAsTitle. searchableFields adds fields to that behavior rather than replacing the title field. To define which fields should be searched, use searchableFields on a list entry in admin.views:
Tip: If you are adding searchable fields, make sure you index each of these fields so your admin queries can remain performant.

List View Select API

The List View uses the Select API to query only the active columns, not whole documents. This keeps large collections fast, but a hook that relies on another field only gets it while that field’s column is shown:
To keep title present, return it from a select function on your Collection Config:

Format Document URLs

The formatDocURL function allows you to customize how document links are generated in the List View. This is useful for disabling links for certain documents, redirecting to custom destinations, or modifying URLs based on user context or document state. To define a custom document URL formatter, use the admin.formatDocURL property in your Collection Config:
The formatDocURL function receives the following arguments: The function should return:
  • null to disable the link entirely (no link will be rendered)
  • A string containing the custom URL to use for the link
  • The defaultURL parameter to use FrogBot’s default linking behavior
Tip: The defaultURL parameter saves you from having to reconstruct URLs manually. You can modify it by appending query parameters or use it as a fallback for your custom logic.

Examples

Disable linking for certain users:

GraphQL

You can completely disable GraphQL for this collection by passing graphQL: false to your collection config. This will completely disable all queries, mutations, and types from appearing in your GraphQL schema. You can also pass an object to the collection’s graphQL property, which allows you to define the following properties:

TypeScript

You can import types from FrogBot to help make writing your Collection configs easier and type-safe. There are two main types that represent the Collection Config, CollectionConfig and SanitizedCollectionConfig. The CollectionConfig type represents a raw Collection Config in its full form, where only the bare minimum properties are marked as required. The SanitizedCollectionConfig type represents a Collection Config after it has been fully sanitized. Generally, this is only used internally by FrogBot.