I'm working on a project where there is an array that I need to go through and query a model from my MongoDB database.
After this query is done, I need to increment another array with the query response, but after I query using await, everything under the query seems to be 'ignored'.
I've tried to return a promise, or even use .then () but nothing works.
const schedules = { all: [], unique: [], final: []};
...
schedules.unique.forEach(async (schedule) => {
const final = await ScheduleRef.findById(schedule);
schedules.final.push(final);
});