I am wondering if i can in N1QL only update a value of an Doc in Array if it is Not Defined or Null in a single stament.
In my case i keep track of email Activity and i want to log when the first time the email was opened. Currently i am using this query
UPDATE Contacts AS d USE KEYS $1 SET e.opened = true, e.activityDate = $3 FOR e IN d.emails WHEN e.tracking_nbr = $2 END, d.metrics.nbr_of_email_opened = d.metrics.nbr_of_email_opened +1 , d.metrics.nbr_of_unique_email_opened = d.metrics.nbr_of_unique_email_opened + CASE WHEN (ANY e IN d.emails SATISFIES e.tracking_nbr = $2 AND (e.opened IS NOT VALUED OR e.opened = false) END) THEN 1 ELSE 0 END` WHERE d._type = "email_campaign" AND ANY e IN d.emails SATISFIES e.tracking_nbr = $2 END
That code will overwrite the activityDate everytime it is called which i want to avoid.