I have an objectId like this: ["56153e4c2040efa61b4e267f","56033932efefe0d8657bbd9e"] To store this information in my model, I use:
items: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Items' }]
What I'm trying to do is extend an array element equal to objectId, which I send from the user interface to the delete request.
The code I'm using is:
_.remove(unit.items, request.params.itemId);
I am using the lodash library.
I am assuming there are ObjectId objects in the array, and I'm trying to compare with a string, which is request.params.itemId.
source share