我的测试环境使用docker 进行的安装
我使用的是timesacledb 复制集版本,参考https://github.com/timescale/streaming-replication-docker
./start_containers.sh
npm install -g postgraphile
psql -U postgres -h localhost
create database appdemo
使用watch 参数可以自动更新api
postgraphile -c "postgres://postgres:postgres@localhost:5432/appdemo" --watch
参考结果
create table person (
id serial primary key,
name varchar not null,
about text,
email varchar not null unique,
created_at timestamp default current_timestamp
);
自动更新结果
<img width="699" height="458" src="7e4d60d1-f7f9-4752-8170-ef9f56a668b2_files/82548778.png">
* 添加数据
```code
mutation {
createPerson(input:{
clientMutationId:"demoappdemo",
person:{
name:"dalong",
about:"demoappdemo",
email:"1141591465@qq.com",
createdAt:"2018-07-10"
}
}){
person {
name
about
email
}
}
}
主要是扩展行行,prisma是多数据库支持的,基于nodejs 开发模式,同时生态不错,有好多相关的组件,使用上主要
以模型优先的模式,postgraphile 相对就简单了,只需要安装基本上不用写代码(当然角色,权限的问题,依然需要处理,
而且在ID的处理上postgraphile有点模糊,还有待仔细阅读。
详细的比较后边会有介绍
https://www.graphile.org/postgraphile/introduction/
https://www.prisma.io/
原文:https://www.cnblogs.com/rongfengliang/p/9265979.html