fix non-returning promise warning

This commit is contained in:
Bilal Catic
2019-08-21 06:45:43 +02:00
parent 5a0426cc12
commit 27cbe1f51c
4 changed files with 74 additions and 28 deletions

View File

@@ -205,27 +205,34 @@ const bulkWriteReservationsWithChangesTracking = (reservations) => {
individualHooks: true,
})
.then(([updateCount, updatedInstances]) => {
if (updateCount === 0){
const oldReservation = {
start: null,
end: null,
resourceId: null,
};
try {
if (updateCount === 0) {
const oldReservation = {
start: null,
end: null,
resourceId: null,
};
changes.push({
oldReservation,
newReservation: reservation,
});
resolve(db.bookingReservation.upsert(reservation));
}else{
resolve();
changes.push({
oldReservation,
newReservation: reservation,
});
db.bookingReservation.upsert(reservation)
.then(() => resolve())
.catch((error) => reject(error));
} else {
resolve();
}
}catch (e) {
console.log('CATCH E : ', e);
reject(e);
}
})
.catch((error) => {
console.log('Error updating');
console.log(error);
reject(error);
})
});
});
};