aboutsummaryrefslogtreecommitdiff
path: root/query/README.md
blob: 54e99af094c3e392ee19f9b63d45e15a99e345c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

   

Query

back to index

The /query endpoint is where all database operations happen. One endpoint, one JSON DERULO format, multiple actions. Pretty much the heart of jsonderulo <3 and whats the minimum requirement for JSON DERULO v1 compliance (in addition to authentication).

Pages

Actions

Features

  • Filters where clauses, structured filters, joins, ordering
  • Batch run multiple queries of the same type in one request

How it works

POST /query with a JSONDERULO body. The action field tells the server what you want to do. The table field tells it which table.

{
  "action": "select",
  "table": "items"
}

Thats the simplest possible query. Selects all columns from the items table with the default limit applied.

Every query should run inside a transaction. The server should set @current_user_id and @request_id as SQL session variables before running your query so triggers and stuff can reference them if needed in your schema.

Auth

Bearer token required. The server should ALWAYS check your permissions for the target table (and any joined tables) before doing anything. See permissions for how that works.

Common Response Fields

Every response has success (boolean). Beyond that:

Action Extra fields
select data (array of rows), optionally warning
insert data (last insert id), rows_affected
update rows_affected, if applicable warning
delete rows_affected, if applicable warning
count data (the count as a number)

The warning field should appear when json derulo striped for you, example : your limit being capped to a maximum or blocked columns being stripped away by json derulo stripping. its not an error just a hey bbgurl please comply to what you're allowed to do and to json derulos orders!