@seekdb/prisma-adapter
v1.2.0
Published
Prisma driver adapter for seekdb Embedded — use Prisma with seekdb Embedded
Readme
@seekdb/prisma-adapter
Prisma driver adapter for seekdb Embedded. Use Prisma with seekdb Embedded.
- Provider:
mysql(seekdb is MySQL-compatible) - Use case: Vector/hybrid search with seekdb Collection API + type-safe relational tables with Prisma, all in one embedded database file.
Requirements
- Node.js ≥ 18
- Prisma ≥ 6 (driver adapters supported; no preview flag needed in 6.19+)
- seekdb Embedded client (created with
pathanddatabase, nothost/port)
Installation
npm install @seekdb/prisma-adapter seekdb @prisma/client
# or
pnpm add @seekdb/prisma-adapter seekdb @prisma/clientSchema
In your schema.prisma:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
id String @id
name String
email String?
}Use provider = "mysql" so Prisma generates MySQL-compatible SQL. DATABASE_URL can be a placeholder when using the adapter (e.g. mysql://localhost/ignored).
Usage
import { SeekdbClient } from "seekdb";
import { PrismaSeekdb } from "@seekdb/prisma-adapter";
import { PrismaClient } from "@prisma/client";
const client = new SeekdbClient({
path: "./seekdb.db",
database: "test",
});
const adapter = new PrismaSeekdb(client);
const prisma = new PrismaClient({ adapter });
async function main() {
await prisma.user.create({
data: { id: "1", name: "Alice", email: "[email protected]" },
});
const users = await prisma.user.findMany();
console.log(users);
await prisma.$disconnect();
}
main();- Create tables with
prisma db pushor migrations (run against the same embedded DB; use a small script that uses the adapter to run migrations). - Do not call
client.close()before you are done with Prisma; the adapter uses the same client. Callprisma.$disconnect()thenclient.close()when shutting down.
Transactions
The adapter supports prisma.$transaction(...). It runs START TRANSACTION / COMMIT / ROLLBACK via client.execute(). Behavior depends on seekdb Embedded supporting these statements.
Server mode
For seekdb Server (or OceanBase), use Prisma with DATABASE_URL (same database, two connections). This adapter is only for Embedded mode.
License
Apache-2.0
