分享

PostgRest

 Jcstone 2020-08-17

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表的选择权限

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多