Skip to content

Commit b43bdf4

Browse files
committed
batch support
1 parent d4eda44 commit b43bdf4

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,9 +1089,39 @@ The above example will add a header "X-Time-Taken" with the number of seconds th
10891089

10901090
You may use the "json" middleware to read/write JSON strings as JSON objects and arrays.
10911091

1092-
'json.columns' => 'details',
1092+
'json.tables' => 'products',
1093+
'json.columns' => 'properties',
10931094

1094-
The "pageLimits" middleware limits the page number and the number records returned from a list operation.
1095+
This will change the output of:
1096+
1097+
GET /records/products/1
1098+
1099+
Without "json" middleware will be:
1100+
1101+
{
1102+
"id": 1,
1103+
"name": "Calculator",
1104+
"price": "23.01",
1105+
"properties": "{\"depth\":false,\"model\":\"TRX-120\",\"width\":100,\"height\":null}",
1106+
}
1107+
1108+
With "json" middleware will be:
1109+
1110+
{
1111+
"id": 1,
1112+
"name": "Calculator",
1113+
"price": "23.01",
1114+
"properties": {
1115+
"depth": false,
1116+
"model": "TRX-120",
1117+
"width": 100,
1118+
"height": null
1119+
},
1120+
}
1121+
1122+
This also applies when creating or modifying JSON string fields (also when using batch operations).
1123+
1124+
NB: JSON string fields cannot be partially updated.
10951125

10961126
### XML middleware
10971127

tests/functional/001_records/093_update_product_json.log

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,39 @@ Content-Type: application/json; charset=utf-8
3434
Content-Length: 170
3535

3636
{"id":1,"name":"Calculator","price":"23.01","properties":{"depth":false,"model":"TRX-120","width":100,"height":null},"created_at":"1970-01-01 01:01:01","deleted_at":null}
37+
===
38+
POST /records/products/
39+
40+
[{"name":"Calc v2","price":"24.01","properties":{"version":"v2"},"created_at":"1970-01-01 01:01:01"},{"name":"Calc v3","price":"25.01","properties":{"version":"v3"},"created_at":"1970-01-01 01:01:01"}]
41+
===
42+
200
43+
Content-Type: application/json; charset=utf-8
44+
Content-Length: 5
45+
46+
[2,3]
47+
===
48+
PUT /records/products/2,3
49+
50+
[{"properties":{"new":true}},{"properties":{"version":"v3","new":true}}]
51+
===
52+
200
53+
Content-Type: application/json; charset=utf-8
54+
Content-Length: 5
55+
56+
[1,1]
57+
===
58+
GET /records/products/2,3
59+
===
60+
200
61+
Content-Type: application/json; charset=utf-8
62+
Content-Length: 258
63+
64+
[{"id":2,"name":"Calc v2","price":"24.01","properties":{"new":true},"created_at":"1970-01-01 01:01:01","deleted_at":null},{"id":3,"name":"Calc v3","price":"25.01","properties":{"version":"v3","new":true},"created_at":"1970-01-01 01:01:01","deleted_at":null}]
65+
===
66+
DELETE /records/products/2,3
67+
===
68+
200
69+
Content-Type: application/json; charset=utf-8
70+
Content-Length: 5
71+
72+
[1,1]

0 commit comments

Comments
 (0)