Im trying to delete a record in my mongodb collection that look like this
{
"name": "do sftp backup",
"data": {
"scheduleId": 95
},
"priority": 0,
"type": "normal",
"nextRunAt": null,
"lastModifiedBy": null,
"lockedAt": {
"$date": "2021-08-03T23:02:44.879Z"
},
"lastRunAt": {
"$date": "2021-08-03T23:02:54.874Z"
}
}
but in need to do the query to find this record by the scheduleId in the data field
this is what im doing in the controller
db.collection('agendaJobs').deleteOne({data: scheduleId}, (error) => {
if(!error) {
console.log('Successfully deleted ');
console.log(error);
client.close();
} else {
console.log(error);
client.close();
}
})
and getting the id by params through postman like this localhost:3000/api/schedule/95