A generator, which takes a Prisma 2 schema.prisma
and generates Sequelize Models.
npm:
npm install prisma-sequelize-generator --save-dev
yarn:
yarn add -D prisma-sequelize-generator
generator client {
provider = "prisma-sequelize-generator"
}
With a custom output path (./sequelize
- default)
generator client {
provider = "prisma-sequelize-generator"
output = "custom-output-path"
}
Additional options
generator client {
provider = "prisma-sequelize-generator"
outputFormat = "typescript"
}
Supported output formats are javascript
(alias js
- default) and typescript
(alias ts
).
prisma:
prisma generate
import { createSequelizeInstance } from './prisma/sequelize';
const { sequelize, models } = createSequelizeInstance({
ssl: true,
dialectOptions: {
connectTimeout: 1000,
},
});
// use `sequelize` instance and `models` in your application to read and write data in your DB
No need to set a connection string, it is set form the datasource
configuration in your schema.prisma
by default.
Node Version | Support |
---|---|
(Maintenance LTS) 12 | βοΈ |
(Active LTS) 14 | βοΈ |
(Current) 16 | βοΈ |