GithubHelp home page GithubHelp logo

egg-prisma's Introduction

简单说明

主要代码就lib/index.js. 和schema.prisma中

generator typegraphql {
  provider = "typegraphql-prisma"
}

仅凭此你就可以享受prisma和GraphQL啦!

scripts

npm run dbgen //npx prisma generate
npm run dbpull //npx prisma db pull
npm run dbmigrate xx //npx prisma migrate dev --name "xx"

我不想clone此仓库

安装关键依赖:

npm i @prisma/client apollo-server-koa [email protected] graphql-fields reflect-metadata class-validator type-graphql typegraphql-prisma 

然后复制lib/index.js 并在app.js中使用即可

//app.js
'use strict';

module.exports = app => {
  require('./lib')(app);
};

为什么不做成插件

并不需要?一串在app.js中的逻辑代码而已哇。

为啥要用Prisma

因为ORM就应该只定义一次!egg-sequelize不仅migrations要重复一次,使用graphql还要重复一次。我也是偶然发现Prisma与typegraphql有集成,可自动生成resovlers。

用GraphQL还是尝试为主,打算做的项目也比较小,不考虑性能。

倒是apollo-server-koa。官方示例和egg示例都没有说怎么加这个中间件,apollo-server-koa的示例我删去一些也能运行, 懵了挺久。

egg-prisma's People

Contributors

boilcy avatar

Stargazers

plain avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.