Simple Elysia.js plugin that helps to use Drizzle ORM schema inside elysia swagger model.
Only Postgresql (via pg-core) was supported now
- bun
- Drizzle ORM
- Elysia.js
bun i elysia-drizzle-schema
or
npm i elysia-drizzle-schema
import { foo } from "../db/schema";
import { parseDrizzleModel, type optionsParams } from "./elysia-drizzle";
import type { PgTable } from "drizzle-orm/pg-core";
const app = new Elysia();
app
.use(swagger())
.model({
foo: parseDrizzleModel(
<PgTable>foo,
<optionsParams>{ exludedColumns: ["id", "uuid"] }
),
})
.put("/", requestController.insert, {
body: "test",
detail: {
summary: "Insert new entity",
},
})
.listener(3000);
optionsParams
defines the default settings. The accepted parameters are:
excludePrimaryKey: boolean
: to programmatically skip theid
fieldexcludedColumns?: Array<string>
: list of extra fields to be skipped
It will dynamically load the parameters of the POST body: