Merge a list of objects to a single object

Hi,

I am relatively new to the N1QL.

I have a query output like this:
[
{‘a’: [1,2,3]},
{‘b’: [4,5,6]},
{‘c’: [10,11]}
]

what is an easy way converting to:

{ ‘a’: [1,2,3], ‘b’:[4,5,6], ‘c’: [10,11]}

Also, Dose Select always return as a list?

Thanks

JL

Select Always returns list. Each one of the list is separate document.
If you need to combine them into one you must Do aggregation query (ARRAY_AGG()) which again list.
If you want convert into single OBJECT is tricky. How do u combine, If you have same field names. which one to take.

If you have single field Object like above. If multiple fields those also works. If duplicates it gives random one because object field must be unique overwrites.

WITH ar AS ([ {"a": [1,2,3]}, {"b": [4,5,6]}, {"c": [10,11]} ]),
     av AS (SELECT RAW ARRAY_FLATTEN(ARRAY_AGG(OBJECT_PAIRS(d)),1) FROM ar AS d)
SELECT RAW OBJECT v.name:v.val FOR v IN d2 END FROM av AS d2;

OR

SELECT RAW OBJECT v.id:v.val FOR v IN (SELECT META(d).id, d AS val FROM default AS d) END;

{ "doc1key": {"a": [1,2,3]},"doc2key": {"b":[4,5,6]}, "doc3key":{"c": [10,11]})