I have a data structure something like
{
“_id”: [
“1234”,
“5678”
],
“id”: “docId”
}
In this document, I want to write a query to remove “1234” from Array. I tried this query.
update sample as d use keys “docId” set d._id=(select ARRAY_REMOVE(t._id, “1234”) as _id FROM sample t use keys “docId”);
But instead of updating the existing _id array, it is inserting an additional array. Something like this
{
“_id”: [
{
“_id”: [
“5678”
]
}
],
“id”: “docId”
}.
Please suggest what I am doing wrong!
Below N1QL should do it
UPDATE sample USE KEYS ["docId"] set `_id` = ARRAY_REMOVE(`_id`,"1234”);