DbConfig
DbConfig =
object
Defined in: packages/db/src/types.ts:135
Configuration for createDb.
Example
Section titled “Example”import { createDb } from "@cfast/db";import * as schema from "./schema";
const db = createDb({ d1: env.DB, schema, grants: resolvedGrants, user: { id: "user-123" }, cache: { backend: "cache-api" },});Properties
Section titled “Properties”cache?
Section titled “cache?”
optionalcache:CacheConfig|false
Defined in: packages/db/src/types.ts:151
Cache configuration, or false to disable caching entirely. Defaults to { backend: "cache-api" }.
d1:
D1Database
Defined in: packages/db/src/types.ts:137
The Cloudflare D1 database binding from env.DB.
grants
Section titled “grants”grants:
Grant[]
Defined in: packages/db/src/types.ts:144
Resolved permission grants for the current user’s role, from resolveGrants().
schema
Section titled “schema”schema:
Record<string,DrizzleTable>
Defined in: packages/db/src/types.ts:142
Drizzle schema object. Must be import * as schema so that keys match
table variable names (required by Drizzle’s relational query API).
user: {
id:string; } |null
Defined in: packages/db/src/types.ts:149
The current user, or null for anonymous access.
When null, the "anonymous" role is used for permission checks.