Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function unlinkGoogleUserAndCalendars(calendarId) {
- const calendar = await Calendar.findOne({ where: { id: calendarId } });
- const googleUser = await GoogleUser.findOne({
- where: { id: calendar.provider_user_id },
- });
- await googleUser.update({ status: 'UNLINKED' });
- const calendars = await Calendar.findAll({
- where: {
- provider_user_id: googleUser.id,
- provider_user_type: 'google',
- },
- });
- await Promise.all(
- calendars.map(calendar => {
- return calendar.unlinkAndForceDestroyFutureEvents();
- }),
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement