Add endpoint that allows to move an event to a different calendar
Jenkins Production Deployment

This commit is contained in:
2024-06-04 11:55:30 +02:00
parent cb85e81d67
commit a38fb20e5a
2 changed files with 80 additions and 0 deletions
@@ -188,3 +188,26 @@ export const deleteEvent = async (event: Event): Promise<boolean> => {
await conn.end();
}
};
/**
* Moves an event to the specified calendar
* @param event The event to move. Has to have the target calendar set already.
*/
export const moveEvent = async (event: Event): Promise<boolean> => {
let conn = await NachklangCalendarDB.getConnection();
try {
const eventQuery = 'UPDATE events SET calendar_id = ? WHERE event_id = ?';
const eventRes = await conn.execute(eventQuery, [event.calendarId, event.eventId]);
await conn.commit();
return eventRes.affectedRows === 1;
} catch (err) {
await conn.rollback();
throw err;
} finally {
// Return connection
await conn.commit();
await conn.end();
}
}