Select columns as different object


#1

Lets say I have document like:

"name": "Test",
"id": 222,
"items": 12,
"added_date": "08/01/201",
"country_name": "United Kindgdom",
"country_code": "GB"

How to select id and items in one object and country_name and country_code in another one?
Wanted result:

{ 
"name": "Test", 
"details": { 
"id": 222, 
"items": 12 }, 
"country": { 
"country_name": "United Kingdom", 
"country_code": "GB" } 
}

#2
SELECT d.name, 
                {d.id, d.items} AS details, 
                {d.country_name, d.country_code} AS country
FROM default AS d
WHERE .....;

If you want change name inside object     {"name": d.country_name, "code": d.country_code} AS country

{d.id, d.items, “cnt”: ARRAY_COUNT(ARRAY true FOR v IN d.sellers WHEN … END) }

During OBJECT construction , it requires fieldname:value pair. If the expression is is identifier it will inherits filedname from expression. If not user has to supply filedname:expression.