Skip to content

πŸ³οΈβ€πŸŒˆβƒ€ Sequelize models generator for prisma schema

License

Notifications You must be signed in to change notification settings

floydspace/prisma-sequelize-generator

Repository files navigation

πŸ³οΈβ€πŸŒˆβƒ€ Prisma Sequelize Generator

A generator, which takes a Prisma 2 schema.prisma and generates Sequelize Models.

Generic badge npm version npm downloads build status Code QL Coverage Status semantic-release GitHub license

Getting Started

1. Install

npm:

npm install prisma-sequelize-generator --save-dev

yarn:

yarn add -D prisma-sequelize-generator

2. Add the generator to the schema

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).

3. Run generation

prisma:

prisma generate

3. Use Sequelize Models to interact with your database

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.

Supported Node Versions

Node Version Support
(Maintenance LTS) 12 βœ”οΈ
(Active LTS) 14 βœ”οΈ
(Current) 16 βœ”οΈ