@nestjs/mongoose

  • Version 10.1.0
  • Published
  • 57.8 kB
  • No dependencies
  • MIT license

Install

npm i @nestjs/mongoose
yarn add @nestjs/mongoose
pnpm add @nestjs/mongoose

Overview

Nest - modern, fast, powerful node.js web framework (@mongoose)

Index

Functions

function getConnectionToken

getConnectionToken: (name?: string) => string;

    function getModelToken

    getModelToken: (model: string, connectionName?: string) => string;

      function InjectConnection

      InjectConnection: (name?: string) => PropertyDecorator & ParameterDecorator;

        function InjectModel

        InjectModel: (
        model: string,
        connectionName?: string
        ) => PropertyDecorator & ParameterDecorator;

          function Prop

          Prop: (options?: PropOptions) => PropertyDecorator;

            function raw

            raw: (definition: Record<string, any>) => Record<string, any>;

              function Schema

              Schema: (options?: mongoose.SchemaOptions) => ClassDecorator;

                function Virtual

                Virtual: (options?: VirtualOptions) => PropertyDecorator;

                  Classes

                  class CannotDetermineTypeError

                  class CannotDetermineTypeError extends Error {}

                    constructor

                    constructor(hostClass: string, propertyKey: string);

                      class DefinitionsFactory

                      class DefinitionsFactory {}

                        method createForClass

                        static createForClass: (target: Type<unknown>) => mongoose.SchemaDefinition;

                          class MongooseModule

                          class MongooseModule {}

                            method forFeature

                            static forFeature: (
                            models?: ModelDefinition[],
                            connectionName?: string
                            ) => DynamicModule;

                              method forFeatureAsync

                              static forFeatureAsync: (
                              factories?: AsyncModelFactory[],
                              connectionName?: string
                              ) => DynamicModule;

                                method forRoot

                                static forRoot: (uri: string, options?: MongooseModuleOptions) => DynamicModule;

                                  method forRootAsync

                                  static forRootAsync: (options: MongooseModuleAsyncOptions) => DynamicModule;

                                    class SchemaFactory

                                    class SchemaFactory {}

                                      method createForClass

                                      static createForClass: <TClass = any>(
                                      target: Type<TClass>
                                      ) => mongoose.Schema<TClass>;

                                        class VirtualsFactory

                                        class VirtualsFactory {}

                                          method inspect

                                          static inspect: <TClass = any>(
                                          target: Type<TClass>,
                                          schema: mongoose.Schema<TClass>
                                          ) => void;

                                            Interfaces

                                            interface AsyncModelFactory

                                            interface AsyncModelFactory
                                            extends Pick<ModuleMetadata, 'imports'>,
                                            Pick<ModelDefinition, 'name' | 'collection' | 'discriminators'> {}

                                              property inject

                                              inject?: any[];

                                                property useFactory

                                                useFactory: (
                                                ...args: any[]
                                                ) => ModelDefinition['schema'] | Promise<ModelDefinition['schema']>;

                                                  interface MongooseModuleAsyncOptions

                                                  interface MongooseModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {}

                                                    property connectionName

                                                    connectionName?: string;

                                                      property inject

                                                      inject?: any[];

                                                        property useClass

                                                        useClass?: Type<MongooseOptionsFactory>;

                                                          property useExisting

                                                          useExisting?: Type<MongooseOptionsFactory>;

                                                            property useFactory

                                                            useFactory?: (
                                                            ...args: any[]
                                                            ) => Promise<MongooseModuleFactoryOptions> | MongooseModuleFactoryOptions;

                                                              interface MongooseModuleOptions

                                                              interface MongooseModuleOptions extends ConnectOptions {}

                                                                property connectionErrorFactory

                                                                connectionErrorFactory?: (error: MongooseError) => MongooseError;

                                                                  property connectionFactory

                                                                  connectionFactory?: (connection: any, name: string) => any;

                                                                    property connectionName

                                                                    connectionName?: string;

                                                                      property lazyConnection

                                                                      lazyConnection?: boolean;

                                                                        property onConnectionCreate

                                                                        onConnectionCreate?: (connection: Connection) => void;

                                                                          property retryAttempts

                                                                          retryAttempts?: number;

                                                                            property retryDelay

                                                                            retryDelay?: number;

                                                                              property uri

                                                                              uri?: string;

                                                                                property verboseRetryLog

                                                                                verboseRetryLog?: boolean;

                                                                                  interface MongooseOptionsFactory

                                                                                  interface MongooseOptionsFactory {}

                                                                                    method createMongooseOptions

                                                                                    createMongooseOptions: () =>
                                                                                    | Promise<MongooseModuleOptions>
                                                                                    | MongooseModuleOptions;

                                                                                      interface VirtualOptions

                                                                                      interface VirtualOptions {}

                                                                                        property get

                                                                                        get?: (...args: any[]) => any;

                                                                                          property options

                                                                                          options?: VirtualTypeOptions;

                                                                                            property set

                                                                                            set?: (...args: any[]) => any;

                                                                                              property subPath

                                                                                              subPath?: string;

                                                                                                Type Aliases

                                                                                                type DiscriminatorOptions

                                                                                                type DiscriminatorOptions = {
                                                                                                name: string;
                                                                                                schema: Schema;
                                                                                                value?: string;
                                                                                                };

                                                                                                  type ModelDefinition

                                                                                                  type ModelDefinition = {
                                                                                                  name: string;
                                                                                                  schema: any;
                                                                                                  collection?: string;
                                                                                                  discriminators?: DiscriminatorOptions[];
                                                                                                  };

                                                                                                    type MongooseModuleFactoryOptions

                                                                                                    type MongooseModuleFactoryOptions = Omit<MongooseModuleOptions, 'connectionName'>;

                                                                                                      type PropOptions

                                                                                                      type PropOptions<T = any> =
                                                                                                      | Partial<mongoose.SchemaDefinitionProperty<T>>
                                                                                                      | mongoose.SchemaType;

                                                                                                        type SchemaOptions

                                                                                                        type SchemaOptions = mongoose.SchemaOptions;

                                                                                                          Package Files (15)

                                                                                                          Dependencies (0)

                                                                                                          No dependencies.

                                                                                                          Dev Dependencies (26)

                                                                                                          Peer Dependencies (4)

                                                                                                          Badge

                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@nestjs/mongoose.

                                                                                                          • Markdown
                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@nestjs/mongoose)
                                                                                                          • HTML
                                                                                                            <a href="https://www.jsdocs.io/package/@nestjs/mongoose"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>