Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:postgrest [2018/08/30 16:00] alfred [Usuario de confianza] |
wiki2:postgrest [2020/05/09 09:25] (actual) |
||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| ====== PostgreSQL for PostgREST ====== | ====== PostgreSQL for PostgREST ====== | ||
| + | * http://postgrest.org/en/v5.0/ | ||
| ===== Crear el schema ===== | ===== Crear el schema ===== | ||
| <code> | <code> | ||
| Línea 25: | Línea 26: | ||
| </code> | </code> | ||
| - | ===== Acciones básicas ===== | + | ===== Acciones básicas mediante llamadas REST ===== |
| + | <code> | ||
| + | # Basic query | ||
| + | curl http://localhost:3000/todos | ||
| + | # Insert | ||
| + | curl http://localhost:3000/todos -X POST \ | ||
| + | -H "Content-Type: application/json" \ | ||
| + | -d '{"task": "do bad thing"}' | ||
| + | |||
| + | # Advanced queries | ||
| + | GET /people?age=lt.13 HTTP/1.1 | ||
| + | GET /people?age=gte.18&student=is.true HTTP/1.1 | ||
| + | GET /people?or=(age.gte.14,age.lte.18) HTTP/1.1 | ||
| + | GET /people?and=(grade.gte.90,student.is.true,or(age.gte.14,age.is.null)) HTTP/1.1 | ||
| + | |||
| + | # Selecting some rows | ||
| + | /people?select=first_name,age | ||
| + | GET /people?order=age.desc,height.asc HTTP/1.1 | ||
| + | GET /people?order=age HTTP/1.1 | ||
| + | GET /people?order=age.nullsfirst HTTP/1.1 | ||
| + | GET /people?order=age.desc.nullslast HTTP/1.1 | ||
| + | |||
| + | # Limits and pagination | ||
| + | GET /people?limit=15&offset=30 HTTP/1.1 | ||
| + | |||
| + | # Stored procedures ─ Every stored procedure in the API-exposed database schema is accessible under the /rpc | ||
| + | POST /rpc/function_name HTTP/1.1 | ||
| + | |||
| + | POST /rpc/add_them HTTP/1.1 { "a": 1, "b": 2 } | ||
| + | GET /rpc/add_them?a=1&b=2 HTTP/1.1 | ||
| + | |||
| + | # Delete | ||
| + | DELETE /user?active=is.false HTTP/1.1 | ||
| + | </code> | ||