prisma连接MongoDB

时间:2019-10-01 13:38:42   收藏:0   阅读:112

安装prisma

1
npm i -g prisma
1
prisma init db  //初始化prima

选择数据库

Set up a new Prisma server or deploy to an existing server? (Use arrow keys)
Set up a new Prisma server for local development (based on docker-compose):

  • ? Use existing database Connect to existing database // 连接本地数据库
  • Create new database Set up a local database using Docker // 新建数据库

Or deploy to an existing Prisma server:

  • Demo server + MySQL database Free development environment hosted in Prisma Cloud //云数据库
  • Use other server Manually provide endpoint of a running Prisma server //云数据库

选择数据库类型

What kind of database do you want to deploy to? (Use arrow keys)

  • ? MySQL MySQL compliant databases like MySQL or MariaDB
  • PostgreSQL PostgreSQL database
  • MongoDB Mongo Database

? Set up a new Prisma server or deploy to an existing server? Use existing database ? What kind of database do you want to deploy to? MongoDB
? Enter MongoDB connection string mongodb://localhost:27017 ? Please select the schema you want to introspect yourdbname
*? Select the programming language for the generated Prisma client Don’t generate

输入连接字符

? Enter MongoDB connection string

1
mongodb://localhost:27017

初始化完成

Created 3 new files:
prisma.yml Prisma service definition
datamodel.prisma GraphQL SDL-based datamodel (foundation for database)
docker-compose.yml Docker configuration file

删除 schema: xxxxx 这行

Next steps:

  1. Open folder: cd db
  2. Start your Prisma server: docker-compose up -d
  3. Deploy your Prisma service: prisma deploy
  4. Read more about Prisma server:

prisma deploy
Creating stage default for service default ?
Deploying service default to stage default to server local 1.4s

Changes:

User (Type)

Applying changes 1.2s

Your Prisma endpoint is live:

HTTP: http://localhost:4466
WS: ws://localhost:4466

You can view & edit your data here:

Prisma Admin: http://localhost:4466/_admin

原文:大专栏  prisma连接MongoDB


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!