I am wondering what the fastest no N1QL way is to delete delete a element from a simple string Array. In my case i have a field called categories which is an Array and can store 0 to many values. So for example i have a doc which looks like this.
{ "Name" : "test user",
"type" : "user",
'category" : ["AA", "BB","CC","DD"]
}
What i am trying to do is to remove lets say BB from the category array. i find a bunch of docs, on arrayAppend etc but nothing how to remove an item directly. So far i solve the problem by doing folowing
Get the Document i want to remove the item from, use lodash to return the index of the value in array and then use the remove
.lookupIn(docID)
.get("categories")
var myIndex = _.indexOf(result.contents[0].value,category )
.mutateIn(docID)
.remove("categories[" + myIndex + "]")
The question is there a better way , faster and simpler or are my 2 only other options to use N1QL or get the whole Array back, use lodash to remove the item in question and then save the new array back via subdoc operations