Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,27 @@ const result = await pool.query('SELECT * FROM users');
**ORM Integration:**
Works with Drizzle, Sequelize, TypeORM - see the `@databricks/lakebase` README and `apps/dev-playground/server/lakebase-examples/` for examples.

### Database Plugin

Application-level layer over Lakebase (beta). Owns schema declaration, type generation, drift detection, auto-mounted CRUD routes, and a typed `db` browser client — all driven by `config/database/schema.ts`. See [`docs/docs/plugins/database.md`](./docs/docs/plugins/database.md) for the full guide.

```typescript
import { createApp, server } from '@databricks/appkit';
import { database } from '@databricks/appkit/beta';

const app = await createApp({ plugins: [server(), database()] });
const cases = await app.database.cases.where({ status: 'New' }).limit(50).toArray();

const enriched = await app.database.cases
.where({ status: 'New' })
.include({ activity_log: { select: ['log_id', 'action'] } })
.toArray();
```

Relations declared via `fk(target)` in `config/database/schema.ts` are exposed on `.include()` (forward = singular, reverse = array). For ad-hoc joins use `app.database.sql\`...\`` inside a custom plugin route.

CLI: `npx appkit db init | introspect | migration generate <name> | migrate up | rls <entity> <spec> | seed | setup:dev | types generate | verify`.

### Frontend-Backend Interaction

```
Expand Down
19 changes: 19 additions & 0 deletions docs/docs/api/appkit/Function.createLakebasePostgrestClient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Function: createLakebasePostgrestClient()

```ts
function createLakebasePostgrestClient(config: LakebasePostgrestClientConfig): unknown;
```

Create a Lakebase PostgREST client.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `config` | [`LakebasePostgrestClientConfig`](Interface.LakebasePostgrestClientConfig.md) | Configuration for creating a Lakebase PostgREST client. |

## Returns

`unknown`

A Lakebase PostgREST client.
20 changes: 20 additions & 0 deletions docs/docs/api/appkit/Function.enumeration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Function: enumeration()

```ts
function enumeration(name: string, values: readonly string[]): AppKitColumnChain;
```

Create an enum column.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `name` | `string` | The name of the enum. |
| `values` | readonly `string`[] | The values of the enum. |

## Returns

[`AppKitColumnChain`](Interface.AppKitColumnChain.md)

The wrapped column chain.
4 changes: 2 additions & 2 deletions docs/docs/api/appkit/Interface.DataPath.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ raw<T>(strings: TemplateStringsArray, ...values: unknown[]): Promise<T[]>;
```

Tagged-template SQL escape hatch. Values are bound as parameters; column
and identifier interpolation is intentionally not supported here — use
`getDrizzle()` from the plugin's exports for that case.
and identifier interpolation is intentionally not supported here — drop
to `appkit.database.getPool().query(...)` if you need that.

#### Type Parameters

Expand Down
46 changes: 46 additions & 0 deletions docs/docs/api/appkit/Interface.LakebasePostgrestClientConfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Interface: LakebasePostgrestClientConfig

Configuration for creating a Lakebase PostgREST client.

## Properties

### dataApiUrl?

```ts
optional dataApiUrl: string;
```

***

### fetch()?

```ts
optional fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `input` | `string` \| `URL` \| `Request` |
| `init?` | `RequestInit` |

#### Returns

`Promise`\<`Response`\>

***

### resolveToken

```ts
resolveToken: LakebaseTokenResolver;
```

***

### schema?

```ts
optional schema: string;
```
5 changes: 5 additions & 0 deletions docs/docs/api/appkit/TypeAlias.LakebasePostgrestClient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Type Alias: LakebasePostgrestClient

```ts
type LakebasePostgrestClient = unknown;
```
15 changes: 15 additions & 0 deletions docs/docs/api/appkit/TypeAlias.LakebaseTokenResolver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Type Alias: LakebaseTokenResolver()

```ts
type LakebaseTokenResolver = () => Promise<string | null>;
```

A function that resolves a Lakebase token.

The default `database` plugin runtime no longer uses the Data API path,
so this is reserved for callers that opt into the PostgREST client
directly via `createLakebasePostgrestClient`.

## Returns

`Promise`\<`string` \| `null`\>
Loading