Format output to be able to use In clause

#1

When using a query to get a list of emails for a user to be used then in a in query I come across the following issue. My query returns something like this

[{ “address” : “user1@email.com”},{“address” : “user2@email.com”}] or I can change it to

{ “address” : [“user1@email.com”,”user2@email.com”]}

How can I use this result in an in clause, which comes from a query of emails in a array of emails in user doc.

I want to now query all emails where the email in [address of the subquery]

#2

Subquery must use RAW and must project single field.

SELECT ... 
FROM default AS d
WHERE d.emialid  IN  (SELECT RAW d1.eaddress FROM default AS d1 WHERE .....);