SELECT c._id AS customer_id, c.name,
NEST_MANY(SELECT o._id AS order_id, o.value
FROM orders o
WHERE o.customer_id = c._id
ORDER BY o._id)
AS orders
FROM customers c
⇒
[
{
"customerId": 0,
"name": "bob",
"orders": [ { "orderId": 0, "value": 26.20 }, { "orderId": 1, "value": 8.99 } ]
},
{
"customerId": 1,
"name": "alice",
"orders": [ { "orderId": 2, "value": 12.34 } ]
}
]