elysia-drizzle-schema
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

Elysia Drizzle Schema

Simple Elysia.js plugin that helps to use Drizzle ORM schema inside elysia swagger model.

Only Postgresql (via pg-core) was supported now

Requirements

  • bun
  • Drizzle ORM
  • Elysia.js

Install

bun i elysia-drizzle-schema

or

npm i elysia-drizzle-schema

Usage

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);

Defaults

optionsParams defines the default settings. The accepted parameters are:

  • excludePrimaryKey: boolean: to programmatically skip the id field
  • excludedColumns?: Array<string>: list of extra fields to be skipped

Result

It will dynamically load the parameters of the POST body:

swagger swagger

Package Sidebar

Install

npm i elysia-drizzle-schema

Weekly Downloads

64

Version

1.0.11

License

MIT

Unpacked Size

5.72 kB

Total Files

6

Last publish

Collaborators

  • edsol