Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amplication/prisma-schema-dsl
JavaScript interface for Prisma Schema DSL
https://github.com/amplication/prisma-schema-dsl
Last synced: 3 months ago
JSON representation
JavaScript interface for Prisma Schema DSL
- Host: GitHub
- URL: https://github.com/amplication/prisma-schema-dsl
- Owner: amplication
- License: mit
- Created: 2020-07-30T11:36:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-19T07:25:26.000Z (about 1 year ago)
- Last Synced: 2024-05-07T21:32:01.297Z (6 months ago)
- Language: TypeScript
- Size: 780 KB
- Stars: 112
- Watchers: 7
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome-prisma - Prisma Schema SDL
README
![Node.js CI](https://github.com/amplication/prisma-schema-dsl/workflows/Node.js%20CI/badge.svg)
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(schema: Schema): Promise`
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): 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 [email protected]: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