@nestjs/mongoose

  • Version 10.0.6
  • Published
  • 54.5 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
      ) => (
      target: object,
      key: string | symbol | undefined,
      index?: number | undefined
      ) => void;

        function InjectModel

        InjectModel: (
        model: string,
        connectionName?: string
        ) => (
        target: object,
        key: string | symbol | undefined,
        index?: number | undefined
        ) => void;

          function Prop

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

            function raw

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

              function Schema

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

                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>;

                                      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;

                                                                          interface MongooseOptionsFactory

                                                                          interface MongooseOptionsFactory {}

                                                                            method createMongooseOptions

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

                                                                              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 (13)

                                                                                        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>