diff --git a/ensalador.js b/ensalador.js index a65c0cc8b2ce757c84251c7ef95c203af2647a1c..daee89a8b8a006836a958439600ce1d760c36056 100644 --- a/ensalador.js +++ b/ensalador.js @@ -162,6 +162,8 @@ class Schedule{ "log": this.log, "lat": this.lat }; + if (! obj.assigned ) + delete obj.assigned // Remove undefined props (usefull when transform into YAML) Object.keys(obj).forEach(key => { @@ -185,7 +187,7 @@ class ScheduleCollection{ toJSON(){ return { - "schedules": this.schedules.map(schedule => {return schedule.toJSON()}), + "schedules": this.schedules.map(schedule => { return schedule? schedule.toJSON() : "{}"}), "id": this.id } } @@ -384,4 +386,4 @@ module.exports = {Ensalador, EnsaladorPart, Schedule, ScheduleCollection, Room, // e.execute((err,schedules) => { // console.log(err,schedules); -// }) \ No newline at end of file +// })