Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/mongoose/types/models.d.ts>mongoose.Model

MongoDB object modeling designed to work in an asynchronous environment.
Go to Latest
interface mongoose.Model
implements [NodeJS.EventEmitter], AcceptsDiscriminator, IndexManager, SessionStarter
import { type mongoose } from "https://deno.land/x/mongoose@8.4.3/types/models.d.ts";
const { Model } = mongoose;

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

Type Parameters

TRawDocType
optional
TQueryHelpers = { }
optional
TInstanceMethods = { }
optional
TVirtuals = { }
optional
THydratedDocumentType = HydratedDocument<TRawDocType, TVirtuals & TInstanceMethods, TQueryHelpers>
optional
TSchema = any

Properties

base: Mongoose

Base Mongoose instance the model uses.

baseModelName: string | undefined

If this is a discriminator model, baseModelName is the name of the base model.

collection: Collection

Collection the model uses.

db: Connection

Connection the model uses.

events: NodeJS.EventEmitter

Event emitter that reports any errors that occurred. Useful for global error handling.

modelName: string

The name of the model

discriminators: { [name: string]: Model<any>; } | undefined

Registered discriminators for this model.

schema: Schema<TRawDocType>

Schema the model uses.

Methods

new<DocType = Partial<TRawDocType>>(
doc?: DocType,
fields?: any | null,
options?: boolean | AnyObject,
): THydratedDocumentType
aggregate<R = any>(pipeline?: PipelineStage[], options?: AggregateOptions): Aggregate<Array<R>>
aggregate<R = any>(pipeline: PipelineStage[]): Aggregate<Array<R>>
castObject(obj: AnyObject, options?: { ignoreCastErrors?: boolean; }): TRawDocType
applyDefaults(obj: AnyObject): AnyObject
applyDefaults(obj: TRawDocType): TRawDocType
bulkWrite<DocContents = TRawDocType>(writes: Array<AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends { } ? DocContents : any)>>, options: MongooseBulkWriteOptions & { ordered: false; }): Promise<mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[]; }; }>

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<DocContents = TRawDocType>(writes: Array<AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends { } ? DocContents : any)>>, options?: MongooseBulkWriteOptions): Promise<mongodb.BulkWriteResult>
bulkSave(documents: Array<Document>, options?: MongooseBulkSaveOptions): Promise<mongodb.BulkWriteResult>

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.

countDocuments(filter?: FilterQuery<TRawDocType>, options?: (mongodb.CountOptions & MongooseBaseQueryOptions<TRawDocType>) | null): QueryWithHelpers<number, THydratedDocumentType, TQueryHelpers, TRawDocType, "countDocuments", TInstanceMethods>

Creates a countDocuments query: counts the number of documents that match filter.

create<DocContents = AnyKeys<TRawDocType>>(docs: Array<TRawDocType | DocContents>, options: CreateOptions & { aggregateErrors: true; }): Promise<(THydratedDocumentType | Error)[]>

Creates a new document or documents

create<DocContents = AnyKeys<TRawDocType>>(docs: Array<TRawDocType | DocContents>, options?: CreateOptions): Promise<THydratedDocumentType[]>
create<DocContents = AnyKeys<TRawDocType>>(doc: DocContents | TRawDocType): Promise<THydratedDocumentType>
create<DocContents = AnyKeys<TRawDocType>>(...docs: Array<TRawDocType | DocContents>): Promise<THydratedDocumentType[]>
createCollection<T extends mongodb.Document>(options?: mongodb.CreateCollectionOptions & Pick<SchemaOptions, "expires">): Promise<mongodb.Collection<T>>

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.

createSearchIndex(description: SearchIndexDescription): Promise<string>

Create an Atlas search index. This function only works when connected to MongoDB Atlas.

deleteMany(filter?: FilterQuery<TRawDocType>, options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null): QueryWithHelpers<mongodb.DeleteResult, THydratedDocumentType, TQueryHelpers, TRawDocType, "deleteMany", TInstanceMethods>

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: FilterQuery<TRawDocType>): QueryWithHelpers<mongodb.DeleteResult, THydratedDocumentType, TQueryHelpers, TRawDocType, "deleteMany", TInstanceMethods>
deleteOne(filter?: FilterQuery<TRawDocType>, options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null): QueryWithHelpers<mongodb.DeleteResult, THydratedDocumentType, TQueryHelpers, TRawDocType, "deleteOne", TInstanceMethods>

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: FilterQuery<TRawDocType>): QueryWithHelpers<mongodb.DeleteResult, THydratedDocumentType, TQueryHelpers, TRawDocType, "deleteOne", TInstanceMethods>
dropSearchIndex(name: string): Promise<void>

Delete an existing Atlas search index by name. This function only works when connected to MongoDB Atlas.

findById<ResultDoc = THydratedDocumentType>(
id: any,
projection: ProjectionType<TRawDocType> | null | undefined,
options: QueryOptions<TRawDocType> & { lean: true; },
): QueryWithHelpers<GetLeanResultType<TRawDocType, TRawDocType, "findOne"> | null, ResultDoc, TQueryHelpers, TRawDocType, "findOne", TInstanceMethods>

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<ResultDoc = THydratedDocumentType>(
id: any,
projection?: ProjectionType<TRawDocType> | null,
options?: QueryOptions<TRawDocType> | null,
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOne", TInstanceMethods>
findById<ResultDoc = THydratedDocumentType>(id: any, projection?: ProjectionType<TRawDocType> | null): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOne", TInstanceMethods>
findOne<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
projection: ProjectionType<TRawDocType> | null | undefined,
options: QueryOptions<TRawDocType> & { lean: true; },
): QueryWithHelpers<GetLeanResultType<TRawDocType, TRawDocType, "findOne"> | null, ResultDoc, TQueryHelpers, TRawDocType, "findOne", TInstanceMethods>

Finds one document.

findOne<ResultDoc = THydratedDocumentType>(
filter?: FilterQuery<TRawDocType>,
projection?: ProjectionType<TRawDocType> | null,
options?: QueryOptions<TRawDocType> | null,
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOne", TInstanceMethods>
findOne<ResultDoc = THydratedDocumentType>(filter?: FilterQuery<TRawDocType>, projection?: ProjectionType<TRawDocType> | null): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOne", TInstanceMethods>
findOne<ResultDoc = THydratedDocumentType>(filter?: FilterQuery<TRawDocType>): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOne", TInstanceMethods>
hydrate(
obj: any,
projection?: AnyObject,
options?: HydrateOptions,
): THydratedDocumentType

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.

init(): Promise<THydratedDocumentType>

This function is responsible for building indexes, unless autoIndex is turned off. Mongoose calls this function automatically when a model is created using mongoose.model() or connection.model(), so you don't need to call it.

insertMany(docs: Array<TRawDocType>): Promise<Array<THydratedDocumentType>>

Inserts one or more new documents as a single insertMany call to the MongoDB server.

insertMany(docs: Array<TRawDocType>, options: InsertManyOptions & { lean: true; }): Promise<Array<Require_id<TRawDocType>>>
insertMany(doc: Array<TRawDocType>, options: InsertManyOptions & { ordered: false; rawResult: true; }): Promise<mongodb.InsertManyResult<Require_id<TRawDocType>> & { mongoose: { validationErrors: (CastError | Error.ValidatorError)[]; results: Array<Error | Object | THydratedDocumentType>; }; }>
insertMany(docs: Array<TRawDocType>, options: InsertManyOptions & { lean: true; rawResult: true; }): Promise<mongodb.InsertManyResult<Require_id<TRawDocType>>>
insertMany(docs: Array<TRawDocType>, options: InsertManyOptions & { rawResult: true; }): Promise<mongodb.InsertManyResult<Require_id<THydratedDocumentType>>>
insertMany(doc: Array<TRawDocType>, options: InsertManyOptions): Promise<Array<THydratedDocumentType>>
insertMany<DocContents = TRawDocType>(docs: Array<DocContents | TRawDocType>, options: InsertManyOptions & { lean: true; }): Promise<Array<Require_id<DocContents>>>
insertMany<DocContents = TRawDocType>(docs: DocContents | TRawDocType, options: InsertManyOptions & { lean: true; }): Promise<Array<Require_id<DocContents>>>
insertMany<DocContents = TRawDocType>(doc: DocContents | TRawDocType, options: InsertManyOptions & { ordered: false; rawResult: true; }): Promise<mongodb.InsertManyResult<Require_id<DocContents>> & { mongoose: { validationErrors: (CastError | Error.ValidatorError)[]; results: Array<Error | Object | MergeType<THydratedDocumentType, DocContents>>; }; }>
insertMany<DocContents = TRawDocType>(docs: Array<DocContents | TRawDocType>, options: InsertManyOptions & { rawResult: true; }): Promise<mongodb.InsertManyResult<Require_id<DocContents>>>
insertMany<DocContents = TRawDocType>(docs: Array<DocContents | TRawDocType>): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, "_id">>>>
insertMany<DocContents = TRawDocType>(doc: DocContents, options: InsertManyOptions & { lean: true; }): Promise<Array<Require_id<DocContents>>>
insertMany<DocContents = TRawDocType>(doc: DocContents, options: InsertManyOptions & { rawResult: true; }): Promise<mongodb.InsertManyResult<Require_id<DocContents>>>
insertMany<DocContents = TRawDocType>(doc: DocContents, options: InsertManyOptions): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, "_id">>>>
insertMany<DocContents = TRawDocType>(docs: Array<DocContents | TRawDocType>, options: InsertManyOptions): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, "_id">>>>
insertMany<DocContents = TRawDocType>(doc: DocContents): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, "_id">>>>
listSearchIndexes(options?: mongodb.ListSearchIndexesOptions): Promise<Array<{ name: string; }>>

List all Atlas search indexes on this model's collection. This function only works when connected to MongoDB Atlas.

populate(docs: Array<any>, options: PopulateOptions | Array<PopulateOptions> | string): Promise<Array<THydratedDocumentType>>

Populates document references.

populate(doc: any, options: PopulateOptions | Array<PopulateOptions> | string): Promise<THydratedDocumentType>
populate<Paths>(docs: Array<any>, options: PopulateOptions | Array<PopulateOptions> | string): Promise<Array<MergeType<THydratedDocumentType, Paths>>>
populate<Paths>(doc: any, options: PopulateOptions | Array<PopulateOptions> | string): Promise<MergeType<THydratedDocumentType, Paths>>
updateSearchIndex(name: string, definition: AnyObject): Promise<void>

Update an existing Atlas search index. This function only works when connected to MongoDB Atlas.

validate(): Promise<void>

Casts and validates the given object against this model's schema, passing the given context to custom validators.

validate(obj: any): Promise<void>
validate(obj: any, pathsOrOptions: PathsToValidate): Promise<void>
validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip; }): Promise<void>
watch<ResultType extends mongodb.Document = any, ChangeType extends mongodb.ChangeStreamDocument = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean; }): mongodb.ChangeStream<ResultType, ChangeType>

Watches the underlying collection for changes using MongoDB change streams.

$where(argument: string | Function): QueryWithHelpers<Array<THydratedDocumentType>, THydratedDocumentType, TQueryHelpers, TRawDocType, "find", TInstanceMethods>

Adds a $where clause to this query

translateAliases(raw: any): any

Translate any aliases fields/conditions so the final query or document object is pure

distinct<DocKey extends string, ResultType = unknown>(field: DocKey, filter?: FilterQuery<TRawDocType>): QueryWithHelpers<Array<DocKey extends keyof TRawDocType ? Unpacked<TRawDocType[DocKey]> : ResultType>, THydratedDocumentType, TQueryHelpers, TRawDocType, "distinct", TInstanceMethods>

Creates a distinct query: returns the distinct values of the given field that match filter.

estimatedDocumentCount(options?: QueryOptions<TRawDocType>): QueryWithHelpers<number, THydratedDocumentType, TQueryHelpers, TRawDocType, "estimatedDocumentCount", TInstanceMethods>

Creates a estimatedDocumentCount query: counts the number of documents in the collection.

exists(filter: FilterQuery<TRawDocType>): QueryWithHelpers<{ _id: InferId<TRawDocType>; } | null, THydratedDocumentType, TQueryHelpers, TRawDocType, "findOne", TInstanceMethods>

Returns a document with its _id if at least one document exists in the database that matches the given filter, and null otherwise.

find<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
projection: ProjectionType<TRawDocType> | null | undefined,
options: QueryOptions<TRawDocType> & { lean: true; },
): QueryWithHelpers<GetLeanResultType<TRawDocType, TRawDocType[], "find">, ResultDoc, TQueryHelpers, TRawDocType, "find", TInstanceMethods>

Creates a find query: gets a list of documents that match filter.

find<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
projection?: ProjectionType<TRawDocType> | null | undefined,
options?: QueryOptions<TRawDocType> | null | undefined,
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "find", TInstanceMethods>
find<ResultDoc = THydratedDocumentType>(filter: FilterQuery<TRawDocType>, projection?: ProjectionType<TRawDocType> | null | undefined): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "find", TInstanceMethods>
find<ResultDoc = THydratedDocumentType>(filter: FilterQuery<TRawDocType>): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "find", TInstanceMethods>
find<ResultDoc = THydratedDocumentType>(): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "find", TInstanceMethods>
findByIdAndDelete<ResultDoc = THydratedDocumentType>(id: mongodb.ObjectId | any, options: QueryOptions<TRawDocType> & { lean: true; }): QueryWithHelpers<GetLeanResultType<TRawDocType, TRawDocType, "findOneAndDelete"> | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndDelete", TInstanceMethods>

Creates a findByIdAndDelete query, filtering by the given _id.

findByIdAndDelete<ResultDoc = THydratedDocumentType>(id: mongodb.ObjectId | any, options: QueryOptions<TRawDocType> & { includeResultMetadata: true; }): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndDelete", TInstanceMethods>
findByIdAndDelete<ResultDoc = THydratedDocumentType>(id?: mongodb.ObjectId | any, options?: QueryOptions<TRawDocType> | null): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndDelete", TInstanceMethods>
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
update: UpdateQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { includeResultMetadata: true; lean: true; },
): QueryWithHelpers<ModifyResult<TRawDocType>, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>

Creates a findOneAndUpdate query, filtering by the given _id.

findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
id: mongodb.ObjectId | any,
update: UpdateQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { lean: true; },
): QueryWithHelpers<GetLeanResultType<TRawDocType, TRawDocType, "findOneAndUpdate"> | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
id: mongodb.ObjectId | any,
update: UpdateQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { includeResultMetadata: true; },
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
id: mongodb.ObjectId | any,
update: UpdateQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { upsert: true; } & ReturnsNewDoc,
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
id?: mongodb.ObjectId | any,
update?: UpdateQuery<TRawDocType>,
options?: QueryOptions<TRawDocType> | null,
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
findByIdAndUpdate<ResultDoc = THydratedDocumentType>(id: mongodb.ObjectId | any, update: UpdateQuery<TRawDocType>): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
findOneAndDelete<ResultDoc = THydratedDocumentType>(filter: FilterQuery<TRawDocType>, options: QueryOptions<TRawDocType> & { lean: true; }): QueryWithHelpers<GetLeanResultType<TRawDocType, TRawDocType, "findOneAndDelete"> | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndDelete", TInstanceMethods>

Creates a findOneAndDelete query: atomically finds the given document, deletes it, and returns the document as it was before deletion.

findOneAndDelete<ResultDoc = THydratedDocumentType>(filter: FilterQuery<TRawDocType>, options: QueryOptions<TRawDocType> & { includeResultMetadata: true; }): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndDelete", TInstanceMethods>
findOneAndDelete<ResultDoc = THydratedDocumentType>(filter?: FilterQuery<TRawDocType> | null, options?: QueryOptions<TRawDocType> | null): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndDelete", TInstanceMethods>
findOneAndReplace<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
replacement: TRawDocType | AnyObject,
options: QueryOptions<TRawDocType> & { lean: true; },
): QueryWithHelpers<GetLeanResultType<TRawDocType, TRawDocType, "findOneAndReplace"> | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndReplace", TInstanceMethods>

Creates a findOneAndReplace query: atomically finds the given document and replaces it with replacement.

findOneAndReplace<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
replacement: TRawDocType | AnyObject,
options: QueryOptions<TRawDocType> & { includeResultMetadata: true; },
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndReplace", TInstanceMethods>
findOneAndReplace<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
replacement: TRawDocType | AnyObject,
options: QueryOptions<TRawDocType> & { upsert: true; } & ReturnsNewDoc,
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndReplace", TInstanceMethods>
findOneAndReplace<ResultDoc = THydratedDocumentType>(
filter?: FilterQuery<TRawDocType>,
replacement?: TRawDocType | AnyObject,
options?: QueryOptions<TRawDocType> | null,
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndReplace", TInstanceMethods>
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
update: UpdateQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { includeResultMetadata: true; lean: true; },
): QueryWithHelpers<ModifyResult<TRawDocType>, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>

Creates a findOneAndUpdate query: atomically find the first document that matches filter and apply update.

findOneAndUpdate<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
update: UpdateQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { lean: true; },
): QueryWithHelpers<GetLeanResultType<TRawDocType, TRawDocType, "findOneAndUpdate"> | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
update: UpdateQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { includeResultMetadata: true; },
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
filter: FilterQuery<TRawDocType>,
update: UpdateQuery<TRawDocType>,
options: QueryOptions<TRawDocType> & { upsert: true; } & ReturnsNewDoc,
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
findOneAndUpdate<ResultDoc = THydratedDocumentType>(
filter?: FilterQuery<TRawDocType>,
update?: UpdateQuery<TRawDocType>,
options?: QueryOptions<TRawDocType> | null,
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, "findOneAndUpdate", TInstanceMethods>
replaceOne<ResultDoc = THydratedDocumentType>(
filter?: FilterQuery<TRawDocType>,
replacement?: TRawDocType | AnyObject,
options?: (mongodb.ReplaceOptions & MongooseQueryOptions<TRawDocType>) | null,
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, "replaceOne", TInstanceMethods>

Creates a replaceOne query: finds the first document that matches filter and replaces it with replacement.

recompileSchema(): void

Apply changes made to this model's schema after this model was compiled.

updateMany<ResultDoc = THydratedDocumentType>(
filter?: FilterQuery<TRawDocType>,
update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null,
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, "updateMany", TInstanceMethods>

Creates a updateMany query: updates all documents that match filter with update.

updateOne<ResultDoc = THydratedDocumentType>(
filter?: FilterQuery<TRawDocType>,
update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null,
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, "updateOne", TInstanceMethods>

Creates a updateOne query: updates the first document that matches filter with update.

where<ResultDoc = THydratedDocumentType>(path: string, val?: any): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "find", TInstanceMethods>

Creates a Query, applies the passed conditions, and returns the Query.

where<ResultDoc = THydratedDocumentType>(obj: object): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "find", TInstanceMethods>
where<ResultDoc = THydratedDocumentType>(): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, "find", TInstanceMethods>