I have a Doc which stores tracking info for some campaigns and i need to check if the user got this one already send.
So the Doc has a Element called emails which is an Array , which holds an object with an email array which can have more then one email address in ti.
is there any major performance difference between both solutions ? Also how would i only return the email docs which match this clause since it will return all if i say emails in select clause
If you are not looking for index then you can use second.
Depends on what output you want.
You can use UNNEST
SELECT em
FROM default AS d
UNNEST d.emails AS em
WHERE "demo@gmail.com" IN em.email
OR
SELECT ARRAY em FOR em IN d.emails WHEN "demo@gmail.com" IN em.email END AS emails
FROM default AS d
WHERE ANY em IN emails SATISFIES "demo@gmail.com" IN em.email END