Operaciones de documentos

Las operaciones de documentos son endpoints de acción sobre una colección.

Autenticación

Requiere Api-Key y Api-Secret, o un token Glue de owner cuando el propietario de la base de datos está permitido.

Insertar: {collection}:insert

1POST /v1/databases/a1b2c3d4-e5f6-7890-abcd-ef1234567890/collections/users:insert HTTP/1.1
2Host: api.hola.cloud
3Api-Key: 1abbe476-6ad6-4b97-9cca-6deb6ab2901d
4Api-Secret: 4bda6d52-762b-4e5d-bed7-85614c13b8bf
5Content-Type: application/jsonl
6
7{"id":"user-1","name":"Alice","role":"admin"}
8{"id":"user-2","name":"Bob","role":"member"}
1{"id":"user-1","name":"Alice","role":"admin"}
2{"id":"user-2","name":"Bob","role":"member"}

Buscar: {collection}:find

 1POST /v1/databases/a1b2c3d4-e5f6-7890-abcd-ef1234567890/collections/users:find HTTP/1.1
 2Host: api.hola.cloud
 3Api-Key: 1abbe476-6ad6-4b97-9cca-6deb6ab2901d
 4Api-Secret: 4bda6d52-762b-4e5d-bed7-85614c13b8bf
 5Content-Type: application/json
 6
 7{
 8  "filter": {
 9    "role": "admin"
10  }
11}
1{"id":"user-1","name":"Alice","role":"admin"}

Obtener por ID

1GET /v1/databases/a1b2c3d4-e5f6-7890-abcd-ef1234567890/collections/users/documents/user-1 HTTP/1.1
2Host: api.hola.cloud
3Api-Key: 1abbe476-6ad6-4b97-9cca-6deb6ab2901d
4Api-Secret: 4bda6d52-762b-4e5d-bed7-85614c13b8bf
1{"id":"user-1","name":"Alice","role":"admin"}

Modificar: {collection}:patch

 1POST /v1/databases/a1b2c3d4-e5f6-7890-abcd-ef1234567890/collections/users:patch HTTP/1.1
 2Host: api.hola.cloud
 3Api-Key: 1abbe476-6ad6-4b97-9cca-6deb6ab2901d
 4Api-Secret: 4bda6d52-762b-4e5d-bed7-85614c13b8bf
 5Content-Type: application/json
 6
 7{
 8  "filter": { "id": "user-1" },
 9  "patch": { "role": "owner" }
10}
1{"id":"user-1","name":"Alice","role":"owner"}

Eliminar: {collection}:remove

1POST /v1/databases/a1b2c3d4-e5f6-7890-abcd-ef1234567890/collections/users:remove HTTP/1.1
2Host: api.hola.cloud
3Api-Key: 1abbe476-6ad6-4b97-9cca-6deb6ab2901d
4Api-Secret: 4bda6d52-762b-4e5d-bed7-85614c13b8bf
5Content-Type: application/json
6
7{
8  "filter": { "id": "user-2" }
9}
1{"id":"user-2","name":"Bob","role":"member"}

Comentarios

Deja un comentario