aboutsummaryrefslogtreecommitdiff
path: root/query/insert.md
blob: 899f8044a10d8474c080e519b62339eb98bd87ce (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

   

Insert

back to query /// home

Add a new row to a table.

Request

{
  "action": "insert",
  "table": "items",
  "data": {
    "name": "New Widget",
    "category_id": 3,
    "price": 24.99,
    "status": "draft"
  }
}

Fields

Field Type Required Notes
action string yes must be "insert"
table string yes target table
data object yes column value pairs to insert

Response

{
  "success": true,
  "data": 42,
  "rows_affected": 1
}

data is the auto increment ID of the newly inserted row (last_insert_id).

Behaviors

  • columns you dont have write access to should cause jsonderulo to start stripping for you and remove the naughty stuff from data. if theres nothing left after stripping you get an error (cant insert nothing lol)
  • system columns should be auto populated:
  • created_by set to your user ID
  • pinned_to set to your user ID (unless you have rwa permission and explicitly set it to someone else)
  • created_at handled by SQL defaults
  • if the table has auto generation rules configured (like auto generated codes or UUIDs) those should get applied automatically
  • you need write permission on the table. read only permission codes like r, rg and ro will give you a nice 403