The sub-doc API can only delete items in an array by index. If you need to delete by Id
, you have a few options.
- Get the whole document and set it back
- Get the whole document, determine the index, and then use that for a sub-doc mutation
- Get the whole array using a sub-doc get, remove the item, and set the whole array back using a sub-doc mutation
- Get the whole array using a sub-doc get, determine the index, and then use that for a sub-doc mutation
- Use a N1QL UPDATE query
For 1-4, you’ll probably want to use the CAS value to provide isolation.