I am wondering how i would tell N1ql to return a single Doc vs a Array with one Doc. I have cases where i know i will only get one or none since i am getting the doc by doc key and since that is unique it is safe.
my query looks like this
SELECT meta().id as DocId, c.*,
OBJECT_CONCAT(history,
{"created_by_name": (SELECT RAW name.fname || " " || name.lname
FROM Contacts USE KEYS "user::" || c.history.created_by)[0],
"updated_by_name": (SELECT RAW name.fname || " " || name.lname
FROM Contacts USE KEYS "user::" || c.history.updated_by)[0]
}) AS history
from Contacts c USE KEYS 'menu_item::8FBA7B0B-566E-47CD-885B-1C08B57F34F6'
I could go and just tell it in my api to only return index 0 of the result but i am wondering how i would do this with the main query