How can i in N1QL either update an existing object in an Array and if it does not exist create a new Object inside the array ? Currently i have the below query where i find the Object inside my array and the replace the object
UPDATE Contacts c USE KEYS $1
SET columns[i] = $3
FOR i: col IN columns WHEN col.colId = $2 END`,
in the above case $3 holds the new or update object and $2 is the colId for the object which is unique
My basic Insert Query looks like this in which case the $2 holds the new object
UPDATE Contacts c USE KEYS $1
SET columns = ARRAY_APPEND(columns,$2)`,
Ideally i would like to find a way to combine both queries into 1