or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-6/

Tenant-aware Catalog Models

Build a NestJS feature module that exposes tenant-aware models backed by MongoDB. The module must register schemas as injectable models on both the default connection and a named connection, and support asynchronous schema registration driven by configuration.

Capabilities

Default book model

  • Importing the module with register registers a Book schema on the default database connection and exposes a provider that can create and read book documents with title, author, and optional tags fields. @test

Named analytics model

  • Providing an analyticsUri when registering sets up an Audit schema on a separate connection named analytics, and the audit model records entries without writing to the default connection collections. @test

Async schema registration

  • Using registerAsync with a factory that awaits config values builds a FeatureFlag schema with a configurable collection name suffix and registers it as an injectable model. @test

Module exports

  • Consumer modules that import the catalog module can inject the Book and Audit models in their own providers without redefining schemas. @test

Implementation

@generates

API

export interface CatalogModuleOptions {
  analyticsUri?: string;
  flagCollectionSuffix?: string;
}

export interface CatalogAsyncOptions {
  inject?: any[];
  useFactory?: (...args: any[]) => Promise<CatalogModuleOptions> | CatalogModuleOptions;
}

export class CatalogModule {
  static register(options: CatalogModuleOptions): DynamicModule;
  static registerAsync(options: CatalogAsyncOptions): DynamicModule;
}

Dependencies { .dependencies }

@nestjs/mongoose { .dependency }

Provides NestJS integration utilities for defining schemas and exposing injectable models bound to MongoDB connections.