码迷,mamicode.com
首页 > 数据库 > 详细

prisma连接MongoDB

时间:2019-10-01 13:38:42      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:poi   完成   maria   database   ice   mariadb   lock   dep   https   

安装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)

  • Created type User
  • Created field id of type ID!
  • Created field name of type String!

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


prisma连接MongoDB

标签:poi   完成   maria   database   ice   mariadb   lock   dep   https   

原文地址:https://www.cnblogs.com/petewell/p/11615157.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!