# elysia-drizzle-schema

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

Latest version **1.0.11** (published 2024-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install elysia-drizzle-schema
pnpm add elysia-drizzle-schema
yarn add elysia-drizzle-schema
bun add elysia-drizzle-schema
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2024-02-12 |
| First published | 2024-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Edsol |
| Maintainers | edsol |
| Keywords | bun, elysia, elysia.js, drizzle, drizzle-orm, swagger |

## Links

- npm: https://www.npmjs.com/package/elysia-drizzle-schema
- Repository: https://github.com/Edsol/elysia-drizzle-schema
- Homepage: https://github.com/Edsol/elysia-drizzle-schema#readme
- Issues: https://github.com/Edsol/elysia-drizzle-schema/issues
- npm.io page: https://npm.io/package/elysia-drizzle-schema

## Dependencies (3)

- [rimraf](https://npm.io/package/rimraf.md) ^5.0.5
- [bun-types](https://npm.io/package/bun-types.md) ^1.0.26
- [drizzle-orm](https://npm.io/package/drizzle-orm.md) ^0.29.3

## Recent versions

- 1.0.11 (latest) — 2024-02-12
- 1.0.10 — 2024-02-12
- 1.0.8 — 2024-02-12
- 1.0.7 — 2024-02-12
- 1.0.6 — 2024-02-12
- 1.0.5 — 2024-02-12
- 1.0.4 — 2024-02-12
- 1.0.3 — 2024-02-12
- 1.0.2 — 2024-02-12
- 1.0.1 — 2024-02-09
- 1.0.0 — 2024-02-09

## README

# Elysia Drizzle Schema

Simple [Elysia.js](https://elysiajs.com) plugin that helps to use [Drizzle ORM](https://orm.drizzle.team/) schema inside elysia swagger [model](https://elysiajs.com/validation/reference-model.html#reference-model).

> Only Postgresql (via pg-core) was supported now

## Requirements

- bun
- Drizzle ORM
- Elysia.js

## Install

```bash
bun i elysia-drizzle-schema
```
or 
```bash
npm i elysia-drizzle-schema
```

## Usage

```ts
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](./docs/images/swagger_example.png)
![swagger](./docs/images/swagger_post_body.png)

---
_Source: https://npm.io/package/elysia-drizzle-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
