This adapter allows you to connect your backframe server to a database using the Drizzle ORM. It is a simple wrapper around the Drizzle ORM and is not meant to be used directly. Infact, you will probably never need to use this package directly. The adapters are only used by backframe internally.
Installation
pnpm add @backframe/adapter-drizzle
Usage
Upon Installation, you will need to do one final thing to get the adapter working. Create a new instance of the DrizzleAdapter
class and pass it:
- Your SQL dialect (
pg
ormysql
orsqlite
) - Your database connection object
- An array of tables to be used by the adapter (see below)
// bf.config.ts
import { DrizzleAdapter } from "@backframe/adapter-drizzle";
import { defineConfig } from "@backframe/core";
import { db } from "./src/db.js"; // drizzle db object
import { posts } from "./src/schema.js"; // drizzle schema
const database = new DrizzleAdapter("pg", db, [{ key: "posts", table: posts }]);
export default defineConfig({
interfaces: {
rest: {},
},
database,
});
And that's it! You're good to go.