У меня есть следующий метод для обновления моего документа:
const findAndDisabledAlert = id => (
AlertModel.findOneAndUpdate({ _id: id }, { $set: { status: 'D' } }, { new: true }, (err, alt) => {
if (err) console.log(err);
return alt;
})
);
Но это не обновляет документ и возвращает ноль, я также попытался без "$ set", но получил тот же результат.
Следующий тест создает оповещение, но не меняет статус:
test('Should create, find and disable an alert', async () => {
const currencyAlert = {
name: 'VTC',
pair: 'BTC',
price: 0.00009241,
condition: 'H',
status: 'D',
exchange: 'BITTREX',
};
const alert = await createAlert(currencyAlert);
const alertDisabled = await findAndDisabledAlert(alert.id);
expect(alertDisabled.status).toBe('D');
});