文档操作
文档操作是集合上的 action 端点。
认证
需要 Api-Key 和 Api-Secret;当数据库 owner 被允许时,也可以使用 Glue owner token。
插入:{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"}
查询:{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"}
根据 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"}
修改:{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"}
删除:{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"}
评论