PostgreSQL + Rest = pRest

PostgreSQL + Rest = pRest

308dfe1398173b9576bc23829fb9b92e?s=128

Felipe Oliveira

August 04, 2018
Tweet

Transcript

  1. pREST PostgreSQL + Rest=

  2. Who we are? Felipe Paes de Oliveira Tech Lead at

    Nuveo Database Specialist at Timbira Fabrízio de Royes Mello
  3. Agenda • Why pREST born? • Why do not use

    Postgrest? • How to use pREST? • What are the pros and cons of pREST in a Software Engineer vision? • What are the pros and cons of pREST in a Database Specialist vision? • What have on the pREST roadmap?
  4. About pREST • Born at Nuveo; • Written in Go;

    • Nuveo Core V2 and others projects starting in parallel; • To optimize time in some basic features creation that involves just to interact database.
  5. Why pREST born? • Born at Nuveo; • Written in

    Go; • Nuveo Core V2 and others projects starting in parallel; • To optimize time in some basic features creation that involves just to interact database.
  6. Why do not use Postgrest? • Postgrest: https://postgrest.org • Postgrest

    is written in Haskell • Difficult to Hire • 1 Dev at Nuveo knows about Haskell
  7. Features • CRUD • Where • Join • Group By

    • Like • JSONB • Permission • Scripts • Migration • More in https://postgres.rest
  8. CRUD /DATABASE/SCHEMA/TABLE GET - Select POST - Insert DELETE -

    Delete PUT/PATCH - Update
  9. Where /DATABASE/SCHEMA/TABLE?FIELD=$OPERATOR.VALUE /DATABASE/SCHEMA/TABLE?FIELD->>JSONFIELD:JSONB=$OPERATOR.V ALUE

  10. Where - operators

  11. Join /DATABASE/SCHEMA/TABLE?_join=Type:Table2:Table.field:Operator:Table2 .field

  12. Scripts • GET /_QUERIES/foo/some_get?field1=bar • POST /_QUERIES/foo/some_create?field1=bar • PUT/PATCH /_QUERIES/foo/some_update?field1=bar

    • DELETE /_QUERIES/foo/some_delete?field1=bar
  13. Scripts queries/ └── foo/ └── some_get.read.sql └── some_create.write.sql └── some_update.update.sql

    └── some_delete.delete.sql
  14. Permission • By default to access all endpoints require JWT

    token
  15. Tables Permission [access] restrict = true # can access only

    the tables listed below [[access.tables]] name = "test" permissions = ["read", "write", "delete"] fields = ["id", "name"] [[access.tables]] name = "testarray" permissions = ["read", "write", "delete"] fields = ["id", "data"]
  16. Migration prest migrate --url driver://url --path ./migrations create migration_file_xyz prest

    migrate --url driver://url --path ./migrations up prest migrate --url driver://url --path ./migrations down prest migrate --url driver://url --path ./migrations redo prest migrate --url driver://url --path ./migrations reset prest migrate --url driver://url --path ./migrations version prest migrate --url driver://url --path ./migrations next +1 prest migrate --url driver://url --path ./migrations next +2 prest migrate --url driver://url --path ./migrations next -n prest migrate --url driver://url --path ./migrations goto 1 prest migrate --url driver://url --path ./migrations goto 10 prest migrate --url driver://url --path ./migrations goto v
  17. What is next? • Transaction support • Rewrite the CLI

    to make more user friendly • Background Worker???
  18. More Info • Docs: http://postgres.rest • Issues: https://github.com/prest/prest/issues • Source

    code: https://github.com/prest
  19. THANK YOU !!! Blog: https://www.felipeweb.net.br/ Twiter: @felipeweb Blog: http://fabriziomello.github.io/ Twiter:

    @fabriziomello