Drizzle
Use Drizzle as the storage adapter for memory, runs, and streams.
Install
npm install @better-agent/drizzle drizzle-orm pgGenerate schema
Generate the Better Agent tables into your Drizzle schema.
npx @better-agent/drizzle generate --dialect pgSupported dialects: pg, mysql, and sqlite.
Use --only when you only want some storage areas.
npx @better-agent/drizzle generate --dialect pg --only memory,runs,streamsSetup
Add the generated schema to your Drizzle schema object, then pass the Drizzle
database to drizzleStorage.
import { betterAgent } from "@better-agent/core";
import { drizzleStorage } from "@better-agent/drizzle";
import { drizzle } from "drizzle-orm/node-postgres";
import { Client } from "pg";
import * as betterAgentSchema from "./better-agent.schema";
const client = new Client({
connectionString: process.env.DATABASE_URL,
});
await client.connect();
const db = drizzle({
client,
schema: {
...betterAgentSchema,
},
});
export const app = betterAgent({
storage: drizzleStorage({
db,
dialect: "postgres",
}),
agents: [supportAgent],
});Options
| Option | Description |
|---|---|
db | Existing Drizzle database instance. |
dialect | postgres, mysql, or sqlite. |
Pass the Drizzle db instance you already use in your app.
Notes
Run your normal Drizzle migration flow after adding the generated schema.
See Storage for what Better Agent stores.
Powered by Farming Labs ORM.