Database Schema
Overview of MongoDB schemas for links, click events, domains, users, and organizations.
Database Schema & Data Models
GoLink is backed by MongoDB using Mongoose ODM. The schema is engineered for high write throughput, rapid key-value redirection lookups, and compound index aggregation for analytics queries.
1. Link Model (Link)
Stores shortened link records scoped to an organization and user.
models/link.schema.ts
Key Fields & Indexes
{ domain, shortLink }: Compound unique index enabling O(1) redirection lookup across both custom and default domains.organizationId: Scopes link queries to the active dashboard workspace.active: Boolean flag allowing instant pausing without deleting historical records.
2. Click Event Model (ClickEvent)
Captures immutable telemetry data whenever a redirect occurs.
models/click-event.schema.ts
3. Domain Model (Domain)
Manages custom branded hostnames registered to an organization.
models/domain.schema.ts
4. Organization & Membership Models
GoLink organizes teams into organizations:
Org: Represents a workspace with an owner, name, and unique URL slug.Member: Connects aUserto anOrgwith specific permission roles (Owner,Admin,Member).User: Core user authentication record managed via Better Auth.
Last updated on October 20, 2026