You need to construct Object according to requirements.
insert into default values("1",{ "bar":{ "a":1, "b":2, "c":3 }, "baz":{ "a":4, "b":5 } });
SELECT OBJECT v.name: {v.val.a} FOR v IN OBJECT_PAIRS(d) END AS obj
FROM default d;
If array you can use foo[*].a because it subscripts, not for objects which needs fields.
https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/arrayfun.html#fn-array-star
The Sub-Document API cannot do this iteration and processing. I believe it may be possible to do this with JSONPath. You can probably also build an index inclusive of projection in this case with Couchbase Views in javascript.