1.0.11 • Published 1 year ago

elysia-drizzle-schema v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

1.0.2

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago