# prisma-schema-dsl

> JavaScript interface for Prisma Schema DSL

Latest version **2.2.0** (published 2023-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install prisma-schema-dsl
pnpm add prisma-schema-dsl
yarn add prisma-schema-dsl
bun add prisma-schema-dsl
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2023-09-19 |
| First published | 2020-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 77.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | amplication-bot, mulygottlieb, levivannoort, overbit, barshimi, morhag, amitbarletz, yuvalhazaz, iddan |
| Keywords | prisma, schema, dsl, javascript, ast, generator |

## Links

- npm: https://www.npmjs.com/package/prisma-schema-dsl
- npm.io page: https://npm.io/package/prisma-schema-dsl

## Dependencies (4)

- [typescript](https://npm.io/package/typescript.md) ^4.1.3
- [lodash.isempty](https://npm.io/package/lodash.isempty.md) ^4.4.0
- [@prisma/internals](https://npm.io/package/@prisma/internals.md) ^4.6.1
- [@types/lodash.isempty](https://npm.io/package/@types/lodash.isempty.md) ^4.4.6

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2023-09-19
- 1.2.4 (beta) — 2022-11-30
- 2.1.6 — 2023-09-03
- 2.1.5 — 2023-09-01
- 2.1.4 — 2023-08-31
- 2.1.3 — 2023-08-09
- 2.1.2 — 2023-05-23
- 2.1.1 — 2023-05-22
- 2.1.0 — 2023-05-22
- 2.0.7 — 2023-03-13
- 2.0.6 — 2023-03-13
- 2.0.5 — 2023-02-28
- 2.0.4 — 2023-01-18
- 2.0.3 — 2022-12-19
- 2.0.2 — 2022-12-14
- … 27 more at https://npm.io/package/prisma-schema-dsl/versions

## README

![Node.js CI](https://github.com/amplication/prisma-schema-dsl/workflows/Node.js%20CI/badge.svg)

<p align="center">
    <img height="120" src="./assets/hero.png" alt="Prisma Schema DSL" />
</p>

JavaScript interface for [Prisma Schema DSL](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema)

## Installation

```
npm install prisma-schema-dsl
```

## API

### Print

#### `print(schema: Schema): Promise<string>`

Prints Prisma schema file from AST.
The schema is formatted using prisma-format.

### Builders

#### `createSchema(models: Model[], dataSource?: DataSource): Schema`

Creates a schema AST object

#### `createEnum(name: string, values: string[], documentation?: string): Enum`

- Creates an enum AST object
- Validates given name argument

#### `createModel(name: string, fields: Array<ScalarField | ObjectField>): Model`

- Creates a model AST object
- Validates given name argument

#### `createScalarField(name: string, type: ScalarType, isList: boolean = false, isRequired: boolean = false, isUnique: boolean = false, isId: boolean = false, isUpdatedAt: boolean = false, default: | null | boolean | CallExpression | number | string = null): ScalarField`

- Creates a scalar field AST object
- Validates given name argument

#### `createObjectField(name: string, type: string, isList: boolean = false, isRequired: boolean = false, relationName: string | null = null, relationToFields: string[] = [], relationToReferences: string[] = [], relationOnDelete: "NONE" = "NONE"): ObjectField`

- Creates an object field AST object
- Validates given name argument

#### `createDataSource(name: string, provider: DataSourceProvider, url: string | DataSourceURLEnv): DataSource`

Creates a data source AST object

## Development

- Clone the repository `git clone git@github.com:amplication/prisma-schema-dsl.git`
- Make sure to use npm@7 `npm i -g npm@7`
- Install the dependencies `npm install`
- Run tests `npm test`

---

Created with <3 by amplication

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