How to return only one doc vs an array with 1 doc

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

Request returns results as always ARRAY. If none empty ARRAY, SDK API provides iterate over results, You can do from client side.

Thanks i just wasn’t sure as in subqueries i can tell it to only return the first like this

"updated_by_name": (SELECT RAW name.fname || " " || name.lname
                           FROM Contacts USE KEYS "user::" || c.history.updated_by)[0]

And yes i just return in nodeJs the result.data[0] which will be the doc without array

Subqueries what you did is right way to do. If you need 0th element only.
If subquery produce no results then it becomes MISSING

(SELECT RAW name.fname || " " || name.lname
                           FROM Contacts USE KEYS "user::" || c.history.updated_by)[0]

Yeah, i just wasnt sure if the 0th element was supported in main query as any variation i tried created a error. So i will just do it in the SDK thanks