CreateDbFn
CreateDbFn = (
grants,user) =>Db
Defined in: packages/admin/src/types.ts:108
Factory function that creates a permission-scoped Db instance per request.
The admin calls this on every request with the authenticated user’s grants and identity so that all CRUD operations respect your permission system.
Parameters
Section titled “Parameters”grants
Section titled “grants”Grant[]
The permission grants resolved for the current user.
The authenticated user, or null for unauthenticated access.
{ id: string; } | null
Returns
Section titled “Returns”A Db instance scoped to the user’s permissions.
Example
Section titled “Example”const db: CreateDbFn = (grants, user) => createDb({ d1: env.DB, schema, grants, user });