@jedmao/prisma2-sdl

Parses a subset of the Prisma 2 schema definition language.


Keywords
node, typescript, prisma, prisma2, sdl, schema, definition, language, parser, ast, pretty, pretty-print, typesc
License
MIT
Install
npm install @jedmao/prisma2-sdl@1.2.0

Documentation

@jedmao/prisma2-sdl

GitHub Actions codecov Commitizen friendly XO code style code style: prettier types: TypeScript

Parses a subset of the Prisma2 Schema Language (PSL).

Installation

npm install @jedmao/prisma2-sdl

Usage

import { parse, prettify } from '@jedmao/prisma2-sdl'
import { readFileSync } from 'fs'

const ast = parse(readFileSync('schema.prisma'))
console.log(prettify(ast))

Limitations

This library only parses a subset of the Prisma2 Schema Language (PSL).

model User {
  id     Int     @id
  name   String
  email  String
  age    Int?
  posts  Post[]
}

model Post {
  id       Int     @id
  title    String
  content  String
  author   User
}

Scripts

The following npm scripts are made available to you in the project root. You can run each of them with npm run <script-name>.

build

Runs the TypeScript compiler.

test

Runs AVA in watch mode, which attempts to run only on changed files.

cover

Runs AVA with coverage, dumping coverage results in ./coverage and showing a text summary in the console output.

commit

Runs Commitizen commit wizard, ensuring that your commit messages conform to Conventional Commits.

Tips

Use the git commit command directly with the -n, --no-verify option to bypasses the pre-commit and commit-msg hooks.