postgraphile 基本试用
2024-09-10 00:58:01
我的测试环境使用docker 进行的安装
基本安装
- pg 数据库
我使用的是timesacledb 复制集版本,参考https://github.com/timescale/streaming-replication-docker
./start_containers.sh
- postgraphile(postgraphql)
npm install -g postgraphile
基本使用
- 创建数据库
psql -U postgres -h localhost
create database appdemo
- 启动postgraphile
使用watch 参数可以自动更新api
postgraphile -c "postgres://postgres:postgres@localhost:5432/appdemo" --watch
参考结果
- 使用graphql playground访问
- 创建表
create table person (
id serial primary key,
name varchar not null,
about text,
email varchar not null unique,
created_at timestamp default current_timestamp
);
自动更新结果
- 数据查询操作
query {
allPeople{
nodes {
id
name
}
}
}
- 添加数据
mutation {
createPerson(input:{
clientMutationId:"demoappdemo",
person:{
name:"dalong",
about:"demoappdemo",
email:"1141591465@qq.com",
createdAt:"2018-07-10"
}
}){
person {
name
about
email
}
}
}
与prisma比较
主要是扩展行行,prisma是多数据库支持的,基于nodejs 开发模式,同时生态不错,有好多相关的组件,使用上主要
以模型优先的模式,postgraphile 相对就简单了,只需要安装基本上不用写代码(当然角色,权限的问题,依然需要处理,
而且在ID的处理上postgraphile有点模糊,还有待仔细阅读。
详细的比较后边会有介绍
参考资料
https://www.graphile.org/postgraphile/introduction/
https://www.prisma.io/
最新文章
- [转载]tlb、tlh和tli文件的关系
- (转载)String.IsNullorEmpty()方法的使用
- 详解;(function ($,window,document,undefined){...})(jQuery,window,document);
- xcode6 使用MJRefresh
- 给debian安装xfce桌面套装
- 【转】emulator: ERROR: Could not load OpenGLES emulation library: lib64OpenglRender.so
- 从开发到部署,使用django创建一个简单可用的个人博客
- 修改apache配置文件去除thinkphp url中的index.php
- UVa816,Ordering Tasks,WA
- poj-1056-IMMEDIATE DECODABILITY(字典)
- 1077. Kuchiguse (20)
- 吴恩达课后作业学习2-week3-tensorflow learning-1-例子学习
- linq总结系列(一)---基础部分
- scala生态圈概览
- CreateUserWizard控件的使用
- 测试开发之Django——No2.Django的安装以及项目创建
- Castle ActiveRecord学习(二)配置、引用、程序启动
- 各种IDE的使用
- 19-[JavaScript]-DOM
- NormalMap &; CubeMap