HI… good day!!
I am new to couchbase and I have a array that i want to be deleted using n1ql,
myArray;[“red”,“blue”,“yellow”]
I want to delete an item in my array… how an I delete it using n1ql?
any help will be appreciated. Thanks
HI… good day!!
I am new to couchbase and I have a array that i want to be deleted using n1ql,
myArray;[“red”,“blue”,“yellow”]
I want to delete an item in my array… how an I delete it using n1ql?
any help will be appreciated. Thanks
Hi and welcome!
You can do
UPDATE ...
SET myArray = ARRAY_REMOVE( myArray, ... )
...;
thanks for this
what if we have myArray: [{ id: 1, name: “a”}, { id: 2, name: “b”}, { id: 3, name: “c”}]
Can we use ARRAY_REMOVE to remove { id: 1, name: ‘a’ } object from myArray ?
UPDATE ...
SET myArray = ARRAY_REMOVE( myArray, { id: 1, name: "a" } )
...;
OR
UPDATE ....
SET myArray = ARRAY v FOR v IN myArray WHEN v.id != 1 END
.....;