Open-Source Wikis

/

Cal.com

/

Primitives

/

Calendar models (Selected and Destination)

calcom/cal.com

Calendar models (Selected and Destination)

Two complementary Prisma models that wire users to their calendars.

SelectedCalendar — what to read from

A SelectedCalendar row says "include this external calendar when computing busy times for this user." A user can have many. They are configured in the dashboard's calendar settings and managed by packages/features/selectedCalendar.

Schema highlights:

  • userIdUser
  • integration (e.g., google_calendar)
  • externalId — the calendar's vendor-side ID (Google calendar ID, Microsoft folder ID, ...)
  • credentialId?Credential
  • eventTypeId? — when set, this selection only applies to one event type (use-event-level-selected-calendars feature)

DestinationCalendar — what to write to

A DestinationCalendar row says "write confirmed bookings to this calendar." A user has at most one default; an event type can override with its own.

Schema highlights:

  • userId?User
  • eventTypeId?EventType (per-event override)
  • integration, externalId, name
  • primaryEmail
  • credentialId?Credential

Relationship

graph LR
    User --> SelectedCalendar
    EventType --> DestinationCalendar
    User --> DestinationCalendar
    SelectedCalendar --> Credential
    DestinationCalendar --> Credential

How they're used

  • SelectedCalendar is read by packages/features/busyTimes to know which calendars to query for free/busy.
  • DestinationCalendar is read by packages/features/bookings/lib/EventManager.ts at booking time to choose where the calendar event lands.

The split makes it possible to say "merge availability from my work + personal calendars, but only book to my work calendar" — a common requirement that single-calendar systems don't handle well.

Where the code lives

Concern File
Selected calendars domain packages/features/selectedCalendar
Destination calendar domain packages/features/calendars (alongside the wider calendar federation)
Settings UI apps/web/modules/settings/.../calendars and packages/platform/atoms/calendar-settings/, selected-calendars/, destination-calendar/
API v2 modules apps/api/v2/src/modules/selected-calendars, apps/api/v2/src/modules/destination-calendars, apps/api/v2/src/modules/cal-unified-calendars

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Calendar models (Selected and Destination) – Cal.com wiki | Factory