How do I make it so that when a specific object's count is "0" in the array, it would be removed from the array. Currently, the issue here is that: Despite the object count being 0, its still in the array. I want to make it so that if the object's count is 0, it wont show in the array. It would be removed.
This is the code. (If the code is incorrect, let me know what I did wrong)
if(getCount(newItem._id) === 0) {
collection.update(
{ _id: newItem._id },
{ $pull: { _id: newItem._id }
}
);
