Skip to content
Functionplugin-mongoosev0.5.4Decorator

RegisterMongooseService

Registers a database service with a typed key.

Associates a service class with a key for dependency injection. The service becomes available via core.db.services[key].

The decorated class declares its schema as a public static schema member, which the plugin reads to build the model once the connection is open. A class without one is a compile error.

RegisterMongooseService<TService>(
    key: TService,
    options?: MongooseServiceRegistrationOptions
): <
    Ctor extends Constructor<MongooseServices[TService]> & {
        schema: mongoose.Schema;
    }
>(
    ctor: Ctor
) => void

TService

The service key type

TService

The service key type

key

key: TService

Service key for registration and type-safe access