В моей коллекции мангустов есть такое поле
MemberMatches: [{ type: mongoose.Types.ObjectId, ref: 'Match'}],
Я хочу удалить из этого массива ObjectId, когда пользователь удаляет совпадение из коллекции Match. Идентификатор совпадения поступает из интерфейса реагирования на серверную часть моего узла, и в моем маршруте это то, что я пробовал до сих пор
const deletedMatch = await MatchRegister.remove({_id: id}) (//remove the match from match collection)
const member = await findamember(name) (find the member using member name from member collection)
const newMatchArray1 = member.MemberMatches.filter(match => match.id !== id)
(filter the array based on the id coming from the front end)
const deletedMember = Member.findOneAndUpdate({MemberName: name}, {$push: {MemberMatches: newMatchArray1}}) (command to rewrite the MemberMatches array back)
Последняя строка не работает. Может кто-нибудь указать мне правильное направление, пожалуйста
Вы получаете ошибки или не видите обновленный результат ??
разобрался чувак. спасибо :)