const options = {
$addToSet: { whoLikes: userId },
$inc: { likesCount: 1 },
new: true,
};
collection.findByIdAndUpdate({ _id: postId }, options)
What I want is increment likesCount only if whoLikes array length is get incremented. Right now likesCount incrementing all the time doesn't matter how many objects inside whoLikes array.
I'm using mongoose, node.js