- Fetching FrogBot data within React Server Components
- Seeding data via Node seed scripts that you write and maintain
- Opening custom Next.js route handlers which feature additional functionality but still rely on FrogBot
- Within Access Control and Hooks
Accessing FrogBot
You can gain access to the currently runningfrogbot object via two ways:
Accessing from args or req
In most places within FrogBot itself, you can access frogbot directly from the arguments of Hooks, Access Control, validation functions, and similar. This is the simplest way to access FrogBot in most cases. Most config functions take the req (Request) object, which has FrogBot bound to it (req.frogbot).
Example:
Importing it
If you want to import FrogBot in places where you don’t have the option to access it from function arguments orreq, you can import it and initialize it.
getFrogBot accepts:
getFrogBot caches the instance. Later calls with the same config return it and ignore these options.
If you’re working in Next.js’ development mode, FrogBot will work with Hot Module Replacement (HMR), and as you make changes to your FrogBot Config, your usage of FrogBot will always be in sync with your changes. In production, getFrogBot simply disables all HMR functionality so you don’t need to write your code any differently. We handle optimization for you in production mode.
If you are accessing FrogBot via function arguments or req.frogbot, HMR is automatically supported if you are using it within Next.js.
For more information about using FrogBot outside of Next.js, click here.
Local options available
You can specify more options within the Local API vs. REST or GraphQL due to the server-only context that they are executed in.
Every operation below accepts these options, except that auth operations and
restoreVersion don’t accept select.
Each operation below lists the options it adds.
Transactions
When your database uses transactions you need to thread req through to all local operations. Postgres uses transactions and MongoDB uses transactions when you are using replica sets. Passing req without transactions is still recommended.Collections
The following Collection operations are available through the Local API:Create#collection-create
Find#collection-find
pagination, page, and limit are three related properties documented
here.Find by ID#collection-find-by-id
Count#collection-count
FindDistinct#collection-find-distinct
Update by ID#collection-update-by-id
Update Many#collection-update-many
Delete#collection-delete
Delete Many#collection-delete-many
Duplicate#collection-duplicate
Fails when the collection sets
disableDuplicate. Field beforeDuplicate hooks run on the copied data.
Versions
If a collection has Versions enabled, these operations are available:Find Versions#collection-find-versions
Find Version by ID#collection-find-version-by-id
Count Versions#collection-count-versions
Restore Version#collection-restore-version
select, plus:
Auth Operations
If a collection hasAuthentication enabled, additional Local API operations will be
available:
Auth
auth doesn’t accept the common options.
Login
select, plus:
Forgot Password
select, plus:
Reset Password
select, plus:
Unlock
select, plus:
Verify
select, plus: