项目使用docker-compose mysql 运行
安装
npm insatll -g prisma
or
yarn global add prisma
创建代码
- 项目结构
├── README.md
├── datamodel.graphql
├── docker-compose.yml
└── prisma.yml
- prisma.yml
endpoint: http://localhost:4466
datamodel: datamodel.graphql
- datamodel
type User{
id: ID! @unique
name: String!
age:Int
appinfo:String
appinfodemo:String
version:Int
}
type Person{
id: ID! @unique
pername:String
age:Int
}
type AppURL {
id: ID! @unique
appname:String
appurl:String
}
type Tweet {
id: ID! @unique
createdAt: DateTime!
text: String!
owner: User!
}
type UserTweet {
id: ID! @unique
handle: String! @unique
name: String!
tweets: [Tweet!]!
}
docker-compose
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.8
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: mysql
host: mysql
port: 3306
user: root
password: prisma
migrations: true
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: prisma
volumes:
- mysql:/var/lib/mysql
ports:
- "3306:3306"
volumes:
mysql:
运行
- 启动docker-compose
docker-compose up -d
- 访问
参考资料
https://github.com/rongfengliang/prisma-demo
https://www.prisma.io/