Hello everyone, I have a document of following structure:
"myInputData": [
{
"language": "fr",
"locale": "CA",
"primary": true
}
],
"region": "US",
etc...
and I would like to add into myInputData another entry with values
{
"language": "en",
"locale": "CA",
"primary": false
}
I can’t seem to figure out the insert without modifying previous data, I would like the outcome to have both values ( language fr and language en)
vsr1
2
UPDATE default AS d
SET d.myInputData = ARRAY_APPEND(d.myInputData, {"language": "en","locale": "CA","primary": false})
WHERE ...
Is there any way to check if such an identical entry already exists in the array before appending it?
Okay so turns out having unique/distinct entries was simple, just added ARRAY_DISTINCT right before ARRAY_APPEND, just like this:
UPDATE default AS d
SET d.myInputData = ARRAY_DISTINCT(ARRAY_APPEND(d.myInputData, {“language”: “en”,“locale”: “CA”,“primary”: false}))
WHERE …