親配列を削除せずに、mongodb でサブ配列を $unset する方法を教えてください。
これは、マングースを使用して実行しているクエリです。
User.findByIdAndUpdate(
req.signedCookies.userid,
{
$addToSet: {
friend: {
friendId: mongoose.Types.ObjectId(req.body.friend),
date_added: new Date()
}
},
$unset: {
notifications: {
receivedRequest: mongoose.Types.ObjectId(req.signedCookies.userid)
}
}
}
);
ただし、これにより通知配列全体が削除されます...