declare module 'mongoose' { import mongodb = require('mongodb'); export interface DiscriminatorOptions { value?: string | number | ObjectId; clone?: boolean; overwriteModels?: boolean; mergeHooks?: boolean; mergePlugins?: boolean; } export interface AcceptsDiscriminator { /** Adds a discriminator type. */ discriminator( name: string | number, schema: Schema, value?: string | number | ObjectId | DiscriminatorOptions ): Model; discriminator( name: string | number, schema: Schema, value?: string | number | ObjectId | DiscriminatorOptions ): Model; } export type MongooseBulkWriteResult = mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[], results: Array } }; export interface MongooseBulkWriteOptions extends mongodb.BulkWriteOptions { session?: ClientSession; skipValidation?: boolean; throwOnValidationError?: boolean; strict?: boolean | 'throw'; /** When false, do not add timestamps to documents. Can be overridden at the operation level. */ timestamps?: boolean; /** set to `false` to skip all user-defined middleware, or `{ pre: false }` / `{ post: false }` to skip only pre or post hooks */ middleware?: boolean | SkipMiddlewareOptions; } interface MongooseBulkSaveOptions extends mongodb.BulkWriteOptions { timestamps?: boolean; session?: ClientSession; validateBeforeSave?: boolean; /** set to `false` to skip all user-defined middleware, or `{ pre: false }` / `{ post: false }` to skip only pre or post hooks */ middleware?: boolean | SkipMiddlewareOptions; } /** * @deprecated use AnyBulkWriteOperation instead */ interface MongooseBulkWritePerWriteOptions { timestamps?: boolean; strict?: boolean | 'throw'; session?: ClientSession; skipValidation?: boolean; } interface HydrateOptions { setters?: boolean; hydratedPopulatedDocs?: boolean; virtuals?: boolean; strict?: boolean | 'throw'; } interface InsertManyOptions extends PopulateOption, SessionOption { limit?: number; // @deprecated, use includeResultMetadata instead rawResult?: boolean; includeResultMetadata?: boolean; ordered?: boolean; lean?: boolean; throwOnValidationError?: boolean; /** set to `false` to skip all user-defined middleware, or `{ pre: false }` / `{ post: false }` to skip only pre or post hooks */ middleware?: boolean | SkipMiddlewareOptions; timestamps?: boolean | QueryTimestampsConfig; } interface InsertManyResult extends mongodb.InsertManyResult { mongoose?: { validationErrors?: Array }; } type UpdateWriteOpResult = mongodb.UpdateResult; type UpdateResult = mongodb.UpdateResult; type DeleteResult = mongodb.DeleteResult; interface ModifyResult { value: Default__v> | null; /** see https://www.mongodb.com/docs/manual/reference/command/findAndModify/#lasterrorobject */ lastErrorObject?: { updatedExisting?: boolean; upserted?: mongodb.ObjectId; }; ok: 0 | 1; } type WriteConcern = mongodb.WriteConcern; /** A list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list. */ type PathsToValidate = string[] | string; /** * @deprecated */ type pathsToValidate = PathsToValidate; interface SaveOptions extends SessionOption { checkKeys?: boolean; j?: boolean; safe?: boolean | WriteConcern; timestamps?: boolean | QueryTimestampsConfig; validateBeforeSave?: boolean; validateModifiedOnly?: boolean; w?: number | string; wtimeout?: number; /** set to `false` to skip all user-defined middleware, or `{ pre: false }` / `{ post: false }` to skip only pre or post hooks */ middleware?: boolean | SkipMiddlewareOptions; } interface CreateOptions extends SaveOptions { ordered?: boolean; aggregateErrors?: boolean; } interface RemoveOptions extends SessionOption, Omit {} interface MongooseBulkWritePerOperationOptions { /** Skip validation for this operation. */ skipValidation?: boolean; /** When false, do not add timestamps. When true, overrides the `timestamps` option set in the `bulkWrite` options. */ timestamps?: boolean; } interface MongooseBulkUpdatePerOperationOptions extends MongooseBulkWritePerOperationOptions { /** When true, allows updating fields that are marked as `immutable` in the schema. */ overwriteImmutable?: boolean; /** When false, do not set default values on insert. */ setDefaultsOnInsert?: boolean; } export type InsertOneModel = mongodb.InsertOneModel & MongooseBulkWritePerOperationOptions; export type ReplaceOneModel = Omit, 'filter'> & { filter: QueryFilter } & MongooseBulkUpdatePerOperationOptions; export type UpdateOneModel = Omit, 'filter'> & { filter: QueryFilter } & MongooseBulkUpdatePerOperationOptions; export type UpdateManyModel = Omit, 'filter'> & { filter: QueryFilter } & MongooseBulkUpdatePerOperationOptions; export type DeleteOneModel = Omit, 'filter'> & { filter: QueryFilter }; export type DeleteManyModel = Omit, 'filter'> & { filter: QueryFilter }; export type AnyBulkWriteOperation = | { insertOne: InsertOneModel } | { replaceOne: ReplaceOneModel } | { updateOne: UpdateOneModel } | { updateMany: UpdateManyModel } | { deleteOne: DeleteOneModel } | { deleteMany: DeleteManyModel }; const Model: Model; /* * Apply common casting logic to the given type, allowing: * - strings for ObjectIds * - strings and numbers for Dates * - strings for Buffers * - strings for UUIDs * - POJOs for subdocuments * - vanilla arrays of POJOs for document arrays * - POJOs and array of arrays for maps */ type CreateObjectWithExtraKeys = T & Record; type ApplyBasicCreateCasting = { [K in keyof T]: NonNullable extends Map ? (Record | Array<[KeyType, ValueType]> | T[K]) : NonNullable extends Types.DocumentArray ? RawSubdocType[] | T[K] : NonNullable extends Document ? CreateObjectWithExtraKeys> | T[K] : NonNullable extends TreatAsPrimitives ? QueryTypeCasting : NonNullable extends object ? CreateObjectWithExtraKeys> | T[K] : QueryTypeCasting; }; type HasLeanOption = 'lean' extends keyof ObtainSchemaGeneric ? ObtainSchemaGeneric['lean'] extends Record ? true : ObtainSchemaGeneric['lean'] : false; /** * Models are fancy constructors compiled from `Schema` definitions. * An instance of a model is called a document. * Models are responsible for creating and reading documents from the underlying MongoDB database */ export interface Model< TRawDocType, TQueryHelpers = {}, TInstanceMethods = {}, TVirtuals = {}, THydratedDocumentType = HydratedDocument, TSchema = any, TLeanResultType = TRawDocType> extends NodeJS.EventEmitter, IndexManager, SessionStarter { new >(doc?: DocType, fields?: any | null, options?: AnyObject): THydratedDocumentType; aggregate(pipeline?: PipelineStage[], options?: AggregateOptions): Aggregate>; aggregate(pipeline: PipelineStage[]): Aggregate>; /** Base Mongoose instance the model uses. */ base: Mongoose; /** * If this is a discriminator model, `baseModelName` is the name of * the base model. */ baseModelName: string | undefined; /* Cast the given POJO to the model's schema */ castObject(obj: AnyObject, options?: { ignoreCastErrors?: boolean }): TRawDocType; /* Apply defaults to the given document or POJO. */ applyDefaults(obj: AnyObject): AnyObject; applyDefaults(obj: TRawDocType): TRawDocType; /* Apply virtuals to the given POJO. */ applyVirtuals(obj: AnyObject, virtalsToApply?: string[]): AnyObject; /** * Apply this model's timestamps to a given POJO, including subdocument timestamps */ applyTimestamps(obj: AnyObject, options?: { isUpdate?: boolean, currentTime?: () => Date }): AnyObject; /** * Sends multiple `insertOne`, `updateOne`, `updateMany`, `replaceOne`, * `deleteOne`, and/or `deleteMany` operations to the MongoDB server in one * command. This is faster than sending multiple independent operations (e.g. * if you use `create()`) because with `bulkWrite()` there is only one network * round trip to the MongoDB server. */ bulkWrite( writes: Array>, options: mongodb.BulkWriteOptions & MongooseBulkWriteOptions & { ordered: false } ): Promise; bulkWrite( writes: Array>, options?: mongodb.BulkWriteOptions & MongooseBulkWriteOptions ): Promise; /** * Sends multiple `save()` calls in a single `bulkWrite()`. This is faster than * sending multiple `save()` calls because with `bulkSave()` there is only one * network round trip to the MongoDB server. */ bulkSave(documents: Array, options?: MongooseBulkSaveOptions): Promise; /** Collection the model uses. */ collection: Collection; /** Creates a `countDocuments` query: counts the number of documents that match `filter`. */ countDocuments( filter?: QueryFilter, options?: (mongodb.CountOptions & MongooseBaseQueryOptions & mongodb.Abortable) | null ): QueryWithHelpers< number, THydratedDocumentType, TQueryHelpers, TRawDocType, 'countDocuments', TInstanceMethods & TVirtuals >; countDocuments( filter?: Query, options?: (mongodb.CountOptions & MongooseBaseQueryOptions & mongodb.Abortable) | null ): QueryWithHelpers< number, THydratedDocumentType, TQueryHelpers, TRawDocType, 'countDocuments', TInstanceMethods & TVirtuals >; /** Creates a new document or documents */ create(): Promise; create(doc: Partial): Promise; create(docs: Array>): Promise; create(docs: Array>>>, options: CreateOptions & { aggregateErrors: true }): Promise<(THydratedDocumentType | Error)[]>; create(docs: Array>>>, options?: CreateOptions): Promise; create(doc: DeepPartial>>): Promise; create(...docs: Array>>>): Promise; /** * Create the collection for this model. By default, if no indexes are specified, * mongoose will not create the collection for the model until any documents are * created. Use this method to create the collection explicitly. */ createCollection(options?: mongodb.CreateCollectionOptions & Pick & { middleware?: boolean | SkipMiddlewareOptions }): Promise>; /** * Create an [Atlas search index](https://www.mongodb.com/docs/atlas/atlas-search/create-index/). * This function only works when connected to MongoDB Atlas. */ createSearchIndex(description: SearchIndexDescription): Promise; /** * Creates all [Atlas search indexes](https://www.mongodb.com/docs/atlas/atlas-search/create-index/) defined in this model's schema. * This function only works when connected to MongoDB Atlas. */ createSearchIndexes(): Promise; /** Connection the model uses. */ db: Connection; /** * Deletes all of the documents that match `conditions` from the collection. * Behaves like `remove()`, but deletes all documents that match `conditions` * regardless of the `single` option. */ deleteMany( filter?: QueryFilter, options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions) | null ): QueryWithHelpers< mongodb.DeleteResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'deleteMany', TInstanceMethods & TVirtuals >; deleteMany( filter?: Query, options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions) | null ): QueryWithHelpers< mongodb.DeleteResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'deleteMany', TInstanceMethods & TVirtuals >; /** * Deletes the first document that matches `conditions` from the collection. * Behaves like `remove()`, but deletes at most one document regardless of the * `single` option. */ deleteOne( filter?: QueryFilter, options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions) | null ): QueryWithHelpers< mongodb.DeleteResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'deleteOne', TInstanceMethods & TVirtuals >; deleteOne( filter?: Query, options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions) | null ): QueryWithHelpers< mongodb.DeleteResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'deleteOne', TInstanceMethods & TVirtuals >; /** Adds a discriminator type. */ discriminator>( name: string | number, schema: TDiscriminatorSchema, value?: string | number | ObjectId | DiscriminatorOptions ): Model< TRawDocType & InferSchemaType, TQueryHelpers & ObtainSchemaGeneric, TInstanceMethods & ObtainSchemaGeneric, TVirtuals & ObtainSchemaGeneric > & ObtainSchemaGeneric & ObtainSchemaGeneric; discriminator( name: string | number, schema: Schema, value?: string | number | ObjectId | DiscriminatorOptions ): Model; discriminator( name: string | number, schema: Schema, value?: string | number | ObjectId | DiscriminatorOptions ): U; /** * Delete an existing [Atlas search index](https://www.mongodb.com/docs/atlas/atlas-search/create-index/) by name. * This function only works when connected to MongoDB Atlas. */ dropSearchIndex(name: string): Promise; /** * Event emitter that reports any errors that occurred. Useful for global error * handling. */ events: NodeJS.EventEmitter; /** * Finds a single document by its _id field. `findById(id)` is almost* * equivalent to `findOne({ _id: id })`. If you want to query by a document's * `_id`, use `findById()` instead of `findOne()`. */ findById( id: any, projection: ProjectionType | null | undefined, options: QueryOptions & { lean: true } ): QueryWithHelpers< TLeanResultType | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOne', TInstanceMethods & TVirtuals >; findById( id?: any, projection?: ProjectionType | null | undefined, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : ResultDoc | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOne', TInstanceMethods & TVirtuals >; /** Finds one document. */ findOne( filter: QueryFilter, projection: ProjectionType | null | undefined, options: QueryOptions & { lean: true } & mongodb.Abortable ): QueryWithHelpers< TLeanResultType | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOne', TInstanceMethods & TVirtuals >; findOne( filter: Query, projection: ProjectionType | null | undefined, options: QueryOptions & { lean: true } & mongodb.Abortable ): QueryWithHelpers< TLeanResultType | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOne', TInstanceMethods & TVirtuals >; findOne( filter?: QueryFilter, projection?: ProjectionType | null | undefined, options?: QueryOptions & mongodb.Abortable | null | undefined ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : ResultDoc | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOne', TInstanceMethods & TVirtuals >; findOne( filter?: Query, projection?: ProjectionType | null | undefined, options?: QueryOptions & mongodb.Abortable | null | undefined ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : THydratedDocumentType | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOne', TInstanceMethods & TVirtuals >; /** * Shortcut for creating a new Document from existing raw data, pre-saved in the DB. * The document returned has no paths marked as modified initially. */ hydrate(obj: any, projection?: ProjectionType, options?: HydrateOptions): THydratedDocumentType; /** * This function is responsible for building [indexes](https://www.mongodb.com/docs/manual/indexes/), * unless [`autoIndex`](http://mongoosejs.com/docs/guide.html#autoIndex) is turned off. * Mongoose calls this function automatically when a model is created using * [`mongoose.model()`](/docs/api/mongoose.html#mongoose_Mongoose-model) or * [`connection.model()`](/docs/api/connection.html#connection_Connection-model), so you * don't need to call it. */ init(): Promise; /** Inserts one or more new documents as a single `insertMany` call to the MongoDB server. */ insertMany( docs: Array ): Promise>; insertMany( doc: Array, options: InsertManyOptions & { ordered: false; rawResult: true; } ): Promise> & { mongoose: { validationErrors: (CastError | Error.ValidatorError)[]; results: Array< Error | Object | THydratedDocumentType > } }>; insertMany( docs: Array, options: InsertManyOptions & { lean: true, rawResult: true; } ): Promise>>; insertMany( doc: DocContents | TRawDocType, options: InsertManyOptions & { ordered: false; rawResult: true; } ): Promise> & { mongoose: { validationErrors: (CastError | Error.ValidatorError)[]; results: Array< Error | Object | MergeType > } }>; insertMany( docs: Array, options: InsertManyOptions & { lean: true; } ): Promise>>; insertMany( docs: Array, options: InsertManyOptions & { rawResult: true; } ): Promise>>; insertMany( docs: Array, options: InsertManyOptions & { lean: true; } ): Promise>>; insertMany( docs: Array, options: InsertManyOptions & { rawResult: true; } ): Promise>>; insertMany( doc: DocContents, options: InsertManyOptions & { lean: true; } ): Promise>>; insertMany( doc: DocContents, options: InsertManyOptions & { rawResult: true; } ): Promise>>; insertMany( doc: Array, options: InsertManyOptions ): Promise>; insertMany( docs: Array ): Promise>>>; insertMany( doc: DocContents, options: InsertManyOptions ): Promise>>>; insertMany( docs: Array, options: InsertManyOptions ): Promise>>>; insertMany( doc: DocContents ): Promise< Array>> >; /** * Shortcut for saving one document to the database. * `MyModel.insertOne(obj, options)` is almost equivalent to `new MyModel(obj).save(options)`. * The difference is that `insertOne()` checks if `obj` is already a document, and checks for discriminators. */ insertOne(doc: Partial>, options?: SaveOptions): Promise; /** * List all [Atlas search indexes](https://www.mongodb.com/docs/atlas/atlas-search/create-index/) on this model's collection. * This function only works when connected to MongoDB Atlas. */ listSearchIndexes(options?: mongodb.ListSearchIndexesOptions): Promise>; /** The name of the model */ modelName: string; /** Populates document references. */ populate( docs: Array, options: PopulateOptions | Array | string ): Promise>; populate( doc: any, options: PopulateOptions | Array | string ): Promise; populate( docs: Array, options: PopulateOptions | Array | string ): Promise, TRawDocType>>>; populate( doc: any, options: PopulateOptions | Array | string ): Promise, TRawDocType>>; /** * Update an existing [Atlas search index](https://www.mongodb.com/docs/atlas/atlas-search/create-index/). * This function only works when connected to MongoDB Atlas. */ updateSearchIndex(name: string, definition: AnyObject): Promise; /** * Changes the Connection instance this model uses to make requests to MongoDB. * This function is most useful for changing the Connection that a Model defined using `mongoose.model()` uses * after initialization. */ useConnection(connection: Connection): this; /** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */ validate(): Promise; validate(obj: any): Promise; validate(obj: any, pathsOrOptions: PathsToValidate): Promise; validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip }): Promise; /** Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/). */ watch(pipeline?: Array>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream; /** Adds a `$where` clause to this query */ $where(argument: string | Function): QueryWithHelpers, THydratedDocumentType, TQueryHelpers, TRawDocType, 'find', TInstanceMethods & TVirtuals>; /** Registered discriminators for this model. */ discriminators: { [name: string]: Model } | undefined; /** Translate any aliases fields/conditions so the final query or document object is pure */ translateAliases(raw: any): any; /** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */ distinct( field: DocKey, filter?: QueryFilter, options?: QueryOptions ): QueryWithHelpers< Array< DocKey extends keyof WithLevel1NestedPaths ? WithoutUndefined[DocKey]>> : unknown >, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'distinct', TInstanceMethods & TVirtuals >; distinct( field: DocKey, filter?: Query, options?: QueryOptions ): QueryWithHelpers< Array< DocKey extends keyof WithLevel1NestedPaths ? WithoutUndefined[DocKey]>> : unknown >, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'distinct', TInstanceMethods & TVirtuals >; /** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */ estimatedDocumentCount(options?: QueryOptions): QueryWithHelpers< number, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'estimatedDocumentCount', TInstanceMethods & TVirtuals >; /** * Returns a document with its `_id` if at least one document exists in the database that matches * the given `filter`, and `null` otherwise. */ exists( filter: QueryFilter ): QueryWithHelpers< { _id: InferId } | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOne', TInstanceMethods & TVirtuals >; exists( filter: Query ): QueryWithHelpers< { _id: InferId } | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOne', TInstanceMethods & TVirtuals >; /** Creates a `find` query: gets a list of documents that match `filter`. */ find( filter: QueryFilter, projection: ProjectionType | null | undefined, options: QueryOptions & { lean: true } & mongodb.Abortable ): QueryWithHelpers< GetLeanResultType, ResultDoc, TQueryHelpers, TLeanResultType, 'find', TInstanceMethods & TVirtuals >; find( filter: Query, projection: ProjectionType | null | undefined, options: QueryOptions & { lean: true } & mongodb.Abortable ): QueryWithHelpers< GetLeanResultType, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'find', TInstanceMethods & TVirtuals >; find( filter?: QueryFilter, projection?: ProjectionType | null | undefined, options?: QueryOptions & mongodb.Abortable ): QueryWithHelpers< ResultDoc[], ResultDoc, TQueryHelpers, TLeanResultType, 'find', TInstanceMethods & TVirtuals >; find( filter?: Query, projection?: ProjectionType | null | undefined, options?: QueryOptions & mongodb.Abortable ): QueryWithHelpers< THydratedDocumentType[], THydratedDocumentType, TQueryHelpers, TLeanResultType, 'find', TInstanceMethods & TVirtuals >; /** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */ findByIdAndDelete( id: mongodb.ObjectId | any, options: QueryOptions & { includeResultMetadata: true, lean: true } ): QueryWithHelpers< ModifyResult, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; findByIdAndDelete( id: mongodb.ObjectId | any, options: QueryOptions & { lean: true } ): QueryWithHelpers< TLeanResultType | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; findByIdAndDelete( id: mongodb.ObjectId | any, options: QueryOptions & { includeResultMetadata: true } ): QueryWithHelpers< HasLeanOption extends true ? ModifyResult : ModifyResult, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; findByIdAndDelete( id?: mongodb.ObjectId | any, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : ResultDoc | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; /** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */ findByIdAndUpdate( filter: QueryFilter, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true, lean: true } ): QueryWithHelpers< ModifyResult, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findByIdAndUpdate( filter: Query, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true, lean: true } ): QueryWithHelpers< ModifyResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findByIdAndUpdate( id: mongodb.ObjectId | any, update: UpdateQuery, options: QueryOptions & { lean: true } ): QueryWithHelpers< TLeanResultType | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findByIdAndUpdate( id: mongodb.ObjectId | any, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true } ): QueryWithHelpers< HasLeanOption extends true ? ModifyResult : ModifyResult, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findByIdAndUpdate( id: mongodb.ObjectId | any, update: UpdateQuery, options: QueryOptions & { upsert: true } & ReturnsNewDoc ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType : ResultDoc, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findByIdAndUpdate( id?: mongodb.ObjectId | any, update?: UpdateQuery, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : ResultDoc | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; /** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */ findOneAndDelete( filter: QueryFilter, options: QueryOptions & { lean: true } ): QueryWithHelpers< TLeanResultType | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; findOneAndDelete( filter: Query, options: QueryOptions & { lean: true } ): QueryWithHelpers< TLeanResultType | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; findOneAndDelete( filter: QueryFilter, options: QueryOptions & { includeResultMetadata: true } ): QueryWithHelpers< HasLeanOption extends true ? ModifyResult : ModifyResult, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; findOneAndDelete( filter: Query, options: QueryOptions & { includeResultMetadata: true } ): QueryWithHelpers< HasLeanOption extends true ? ModifyResult : ModifyResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; findOneAndDelete( filter?: QueryFilter | null, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TRawDocType | null : ResultDoc | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; findOneAndDelete( filter?: Query | null, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TRawDocType | null : THydratedDocumentType | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndDelete', TInstanceMethods & TVirtuals >; /** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */ findOneAndReplace( filter: QueryFilter, replacement: TRawDocType | AnyObject, options: QueryOptions & { lean: true } ): QueryWithHelpers< TLeanResultType | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndReplace', TInstanceMethods & TVirtuals >; findOneAndReplace( filter: Query, replacement: TRawDocType | AnyObject, options: QueryOptions & { lean: true } ): QueryWithHelpers< TLeanResultType | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndReplace', TInstanceMethods & TVirtuals >; findOneAndReplace( filter: QueryFilter, replacement: TRawDocType | AnyObject, options: QueryOptions & { includeResultMetadata: true } ): QueryWithHelpers< HasLeanOption extends true ? ModifyResult : ModifyResult, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndReplace', TInstanceMethods & TVirtuals >; findOneAndReplace( filter: Query, replacement: TRawDocType | AnyObject, options: QueryOptions & { includeResultMetadata: true } ): QueryWithHelpers< HasLeanOption extends true ? ModifyResult : ModifyResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndReplace', TInstanceMethods & TVirtuals >; findOneAndReplace( filter: QueryFilter, replacement: TRawDocType | AnyObject, options: QueryOptions & { upsert: true } & ReturnsNewDoc ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType : ResultDoc, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndReplace', TInstanceMethods & TVirtuals >; findOneAndReplace( filter: Query, replacement: TRawDocType | AnyObject, options: QueryOptions & { upsert: true } & ReturnsNewDoc ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType : THydratedDocumentType, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndReplace', TInstanceMethods & TVirtuals >; findOneAndReplace( filter?: QueryFilter, replacement?: TRawDocType | AnyObject, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : ResultDoc | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndReplace', TInstanceMethods & TVirtuals >; findOneAndReplace( filter?: Query, replacement?: TRawDocType | AnyObject, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : THydratedDocumentType | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndReplace', TInstanceMethods & TVirtuals >; /** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */ findOneAndUpdate( filter: QueryFilter, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true, lean: true } ): QueryWithHelpers< ModifyResult, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter: Query, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true, lean: true } ): QueryWithHelpers< ModifyResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter: QueryFilter, update: UpdateQuery, options: QueryOptions & { lean: true } ): QueryWithHelpers< GetLeanResultType | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter: Query, update: UpdateQuery, options: QueryOptions & { lean: true } ): QueryWithHelpers< GetLeanResultType | null, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter: QueryFilter, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true } ): QueryWithHelpers< HasLeanOption extends true ? ModifyResult : ModifyResult, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter: Query, update: UpdateQuery, options: QueryOptions & { includeResultMetadata: true } ): QueryWithHelpers< HasLeanOption extends true ? ModifyResult : ModifyResult, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter: QueryFilter, update: UpdateQuery, options: QueryOptions & { upsert: true } & ReturnsNewDoc ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType : ResultDoc, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter: Query, update: UpdateQuery, options: QueryOptions & { upsert: true } & ReturnsNewDoc ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType : THydratedDocumentType, THydratedDocumentType, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter?: QueryFilter, update?: UpdateQuery, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : ResultDoc | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; findOneAndUpdate( filter?: Query, update?: UpdateQuery, options?: QueryOptions | null ): QueryWithHelpers< HasLeanOption extends true ? TLeanResultType | null : ResultDoc | null, ResultDoc, TQueryHelpers, TLeanResultType, 'findOneAndUpdate', TInstanceMethods & TVirtuals >; /** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */ replaceOne( filter?: QueryFilter, replacement?: TRawDocType | AnyObject, options?: (mongodb.ReplaceOptions & QueryOptions) | null ): QueryWithHelpers; replaceOne( filter?: Query, replacement?: TRawDocType | AnyObject, options?: (mongodb.ReplaceOptions & QueryOptions) | null ): QueryWithHelpers; /** Apply changes made to this model's schema after this model was compiled. */ recompileSchema(): void; /** Schema the model uses. */ schema: TSchema; /** Creates a `updateMany` query: updates all documents that match `filter` with `update`. */ updateMany( filter: QueryFilter, update: UpdateQuery | UpdateWithAggregationPipeline, options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions) | null ): QueryWithHelpers; updateMany( filter: Query, update: UpdateQuery | UpdateWithAggregationPipeline, options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions) | null ): QueryWithHelpers; /** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */ updateOne( filter: QueryFilter, update: UpdateQuery | UpdateWithAggregationPipeline, options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions) | null ): QueryWithHelpers; updateOne( filter: Query, update: UpdateQuery | UpdateWithAggregationPipeline, options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions) | null ): QueryWithHelpers; /** Creates a Query, applies the passed conditions, and returns the Query. */ where( path: string, val?: any ): QueryWithHelpers extends true ? TRawDocType[] : ResultDoc[], ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>; where(obj: object): QueryWithHelpers< HasLeanOption extends true ? TRawDocType[] : ResultDoc[], ResultDoc, TQueryHelpers, TLeanResultType, 'find', TInstanceMethods & TVirtuals >; where(): QueryWithHelpers< HasLeanOption extends true ? TRawDocType[] : ResultDoc[], ResultDoc, TQueryHelpers, TLeanResultType, 'find', TInstanceMethods & TVirtuals >; /** * If auto encryption is enabled, returns a ClientEncryption instance that is configured with the same settings that * Mongoose's underlying MongoClient is using. If the client has not yet been configured, returns null. */ clientEncryption(): mongodb.ClientEncryption | null; } }