or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

Inherited Profile Virtuals

Build base and derived profile schemas that rely on virtual fields defined once on the base class. Virtuals must include getter and setter hooks and preserve configuration through inheritance.

Capabilities

Full name virtual persists

  • Creating a document from the derived profile class yields a computed fullName virtual that concatenates first and last names declared on the base class; updating either name updates fullName immediately. @test
  • Assigning a fullName string (e.g., "Ava Cole") to a derived profile document splits it into first and last names stored on the underlying fields. @test

Relational virtual options

  • The derived profile declares a virtual relationship to a mentor entity configured with options (reference, local field, foreign field, justOne) and populating it returns a single mentor document tied to mentorId. @test

Deeper inheritance propagation

  • A second-level subclass of the derived profile gains both the fullName virtual and the mentor virtual without redefining them, including their getter/setter behaviors and options. @test

Implementation

@generates

API

export class BaseProfile {
  firstName: string;
  lastName: string;
  mentorId?: string;
  birthYear?: number;
}

export class StaffProfile extends BaseProfile {
  role: string;
  startYear: number;
}

export class LeadProfile extends StaffProfile {
  teamName: string;
}

export function registerProfiles(connection: unknown): {
  baseModel: unknown;
  staffModel: unknown;
  leadModel: unknown;
};

Dependencies { .dependencies }

@nestjs/mongoose { .dependency }

Provides schema decorators and utilities for defining and inheriting virtual fields with getter/setter hooks.

@satisfied-by