I am looking to save each day of the year in the Mongo Database but I'm unsure about the best approach. I have tried using the $push method and .update method, however, neither seem to be suitable for this scenario.
This is my controller:
exports.reflux = (req, res) => {
const newDay = new Calendar();
for(let i=3; i<367; i++) {
newDay({$push: {day: new Date(new Date().getFullYear(), 0, i), offWork: true, description: ' '}});
}
// for(let i=3; i<367; i++){
//
// {$push: {newDay.day = new Date(new Date().getFullYear(), 0, i);}}
// newDay.day =
// newDay.offWork = true;
// newDay.description = '';
// }
newDay.save();
};
The desired outcome is a collection of documents representing each day of the year.