This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user