1、运行 在postgrest执行文件目录下创建config文件,如tutorial.conf: db-uri = "postgres://authenticator:mysecretpassword@localhost:5433/postgres" db-schema = "api" db-anon-role = "web_anon" 运行命令: ./postgrest tutorial.conf 如下提示则标明postgrest正常运行: Listening on port 3000 Attempting to connect to the database... Connection successful 注意role是在postgresql数据库中创建的角色,并对角色授权数据表的选择、添加、更新、删除等权限: 创建一个用于匿名Web请求的角色。收到请求时,PostgREST将切换到数据库中的该角色以运行查询。 create role web_anon nologin; grant usage on schema api to web_anon; grant select on api.todos to web_anon; api为数据库,todos为表名称,创建匿名角色,赋予todos表的选择权限 |
|