interfaceModel<T, TQueryHelpers ={}, TMethods ={}>extendsNodeJS.EventEmitter, AcceptsDiscriminator {new(doc?: AnyKeys<T>& AnyObject): EnforceDocument<T, TMethods>;
aggregate<R= any>(pipeline?: any[]): Aggregate<Array<R>>;
aggregate<R= any>(pipeline: any[],cb: Function): Promise<Array<R>>;/** Base Mongoose instance the model uses. */base:typeof mongoose;/**
* If this is a discriminator model, `baseModelName` is the name of
* the base model.
*/baseModelName: string |undefined;/**
* 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 round
* trip to MongoDB.
*/bulkWrite(writes: Array<any>, options?: mongodb.CollectionBulkWriteOptions): Promise<mongodb.BulkWriteOpResultObject>;bulkWrite(writes: Array<any>, options?: mongodb.CollectionBulkWriteOptions, cb?: Callback<mongodb.BulkWriteOpResultObject>):void;/**
* 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<Document>): Promise<mongodb.BulkWriteResult>;/** Collection the model uses. */collection: Collection;/** Creates a `count` query: counts the number of documents that match `filter`. */count(callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers,T>;count(filter: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `countDocuments` query: counts the number of documents that match `filter`. */countDocuments(callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers,T>;countDocuments(filter: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a new document or documents */create(docs:(T| DocumentDefinition<T>| AnyObject)[], options?: SaveOptions): Promise<EnforceDocument<T, TMethods>[]>;create(docs:(T| DocumentDefinition<T>| AnyObject)[],callback: Callback<EnforceDocument<T, TMethods>[]>):void;create(doc:T| DocumentDefinition<T>| AnyObject): Promise<EnforceDocument<T, TMethods>>;create(doc:T| DocumentDefinition<T>| AnyObject,callback: Callback<EnforceDocument<T, TMethods>>):void;
create<DocContents =T| DocumentDefinition<T>>(docs: DocContents[], options?: SaveOptions): Promise<EnforceDocument<T, TMethods>[]>;
create<DocContents =T| DocumentDefinition<T>>(docs: DocContents[],callback: Callback<EnforceDocument<T, TMethods>[]>):void;
create<DocContents =T| DocumentDefinition<T>>(doc: DocContents): Promise<EnforceDocument<T, TMethods>>;
create<DocContents =T| DocumentDefinition<T>>(...docs: DocContents[]): Promise<EnforceDocument<T, TMethods>[]>;
create<DocContents =T| DocumentDefinition<T>>(doc: DocContents,callback: Callback<EnforceDocument<T, TMethods>>):void;/**
* 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.CollectionCreateOptions): Promise<mongodb.Collection<T>>;createCollection(options: mongodb.CollectionCreateOptions |null,callback: Callback<mongodb.Collection<T>>):void;/**
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#createIndex)
* function.
*/createIndexes(callback?: CallbackWithoutResult): Promise<void>;createIndexes(options?: any, callback?: CallbackWithoutResult): Promise<void>;/** 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?: FilterQuery<T>, options?: QueryOptions, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result']&{ deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers,T>;deleteMany(filter: FilterQuery<T>,callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result']&{ deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers,T>;deleteMany(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result']&{ deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/**
* 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<T>, options?: QueryOptions, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result']&{ deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers,T>;deleteOne(filter: FilterQuery<T>,callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result']&{ deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers,T>;deleteOne(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result']&{ deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/**
* Sends `createIndex` commands to mongo for each index declared in the schema.
* The `createIndex` commands are sent in series.
*/ensureIndexes(callback?: CallbackWithoutResult): Promise<void>;ensureIndexes(options?: any, callback?: CallbackWithoutResult): Promise<void>;/**
* 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?: any |null, options?: QueryOptions |null, callback?: Callback<EnforceDocument<T, TMethods>|null>): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Finds one document. */findOne(filter?: FilterQuery<T>, projection?: any |null, options?: QueryOptions |null, callback?: Callback<EnforceDocument<T, TMethods>|null>): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/**
* 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): EnforceDocument<T, TMethods>;/**
* This function is responsible for building [indexes](https://docs.mongodb.com/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.html#mongoose_Mongoose-model) or
* [`connection.model()`](/docs/api.html#connection_Connection-model), so you
* don't need to call it.
*/init(callback?: CallbackWithoutResult): Promise<EnforceDocument<T, TMethods>>;/** Inserts one or more new documents as a single `insertMany` call to the MongoDB server. */insertMany(docs: Array<T| DocumentDefinition<T>| AnyObject>,options: InsertManyOptions &{rawResult:true}): Promise<InsertManyResult>;insertMany(docs: Array<T| DocumentDefinition<T>| AnyObject>, options?: InsertManyOptions): Promise<Array<EnforceDocument<T, TMethods>>>;insertMany(doc:T| DocumentDefinition<T>| AnyObject,options: InsertManyOptions &{rawResult:true}): Promise<InsertManyResult>;insertMany(doc:T| DocumentDefinition<T>| AnyObject, options?: InsertManyOptions): Promise<EnforceDocument<T, TMethods>>;insertMany(doc:T| DocumentDefinition<T>| AnyObject, options?: InsertManyOptions, callback?: Callback<EnforceDocument<T, TMethods>| InsertManyResult>):void;insertMany(docs: Array<T| DocumentDefinition<T>| AnyObject>, options?: InsertManyOptions, callback?: Callback<Array<EnforceDocument<T, TMethods>>| InsertManyResult>):void;/**
* Lists the indexes currently defined in MongoDB. This may or may not be
* the same as the indexes defined in your schema depending on whether you
* use the [`autoIndex` option](/docs/guide.html#autoIndex) and if you
* build indexes manually.
*/listIndexes(callback: Callback<Array<any>>):void;listIndexes(): Promise<Array<any>>;/** The name of the model */modelName: string;/** Populates document references. */populate(docs: Array<any>,options: PopulateOptions | Array<PopulateOptions>| string,
callback?: Callback<(EnforceDocument<T, TMethods>)[]>): Promise<Array<EnforceDocument<T, TMethods>>>;populate(doc: any,options: PopulateOptions | Array<PopulateOptions>| string,
callback?: Callback<EnforceDocument<T, TMethods>>): Promise<EnforceDocument<T, TMethods>>;/**
* Makes the indexes in MongoDB match the indexes defined in this model's
* schema. This function will drop any indexes that are not defined in
* the model's schema except the `_id` index, and build any indexes that
* are in your schema but not in MongoDB.
*/syncIndexes(options?: Record<string, unknown>): Promise<Array<string>>;syncIndexes(options: Record<string, unknown>|null,callback: Callback<Array<string>>):void;/**
* Does a dry-run of Model.syncIndexes(), meaning that
* the result of this function would be the result of
* Model.syncIndexes().
*/diffIndexes(options?: Record<string, unknown>): Promise<IndexesDiff>diffIndexes(options: Record<string, unknown>|null,callback:(err: CallbackError,diff: IndexesDiff)=>void):void/**
* Starts a [MongoDB session](https://docs.mongodb.com/manual/release-notes/3.6/#client-sessions)
* for benefits like causal consistency, [retryable writes](https://docs.mongodb.com/manual/core/retryable-writes/),
* and [transactions](http://thecodebarbarian.com/a-node-js-perspective-on-mongodb-4-transactions.html).
* */startSession(options?: mongodb.SessionOptions, cb?: Callback<mongodb.ClientSession>): Promise<mongodb.ClientSession>;/** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */validate(callback?: CallbackWithoutResult): Promise<void>;validate(optional: any, callback?: CallbackWithoutResult): Promise<void>;validate(optional: any,pathsToValidate: string[], callback?: CallbackWithoutResult): Promise<void>;/** Watches the underlying collection for changes using [MongoDB change streams](https://docs.mongodb.com/manual/changeStreams/). */watch(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions): mongodb.ChangeStream;/** Adds a `$where` clause to this query */$where(argument: string | Function): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Registered discriminators for this model. */discriminators:{[name: string]: Model<any>}|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: string, filter?: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<Array<any>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */estimatedDocumentCount(options?: QueryOptions, callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/**
* Returns true if at least one document exists in the database that matches
* the given `filter`, and false otherwise.
*/exists(filter: FilterQuery<T>): Promise<boolean>;exists(filter: FilterQuery<T>,callback: Callback<boolean>):void;/** Creates a `find` query: gets a list of documents that match `filter`. */find(callback?: Callback<EnforceDocument<T, TMethods>[]>): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;find(filter: FilterQuery<T>, callback?: Callback<T[]>): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;find(filter: FilterQuery<T>, projection?: any |null, options?: QueryOptions |null, callback?: Callback<EnforceDocument<T, TMethods>[]>): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */findByIdAndDelete(id?: mongodb.ObjectId | any, options?: QueryOptions |null, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>|null,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `findByIdAndRemove` query, filtering by the given `_id`. */findByIdAndRemove(id?: mongodb.ObjectId | any, options?: QueryOptions |null, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>|null,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */findByIdAndUpdate(id: mongodb.ObjectId | any,update: UpdateQuery<T>| UpdateWithAggregationPipeline,options: QueryOptions &{rawResult:true}, callback?:(err: CallbackError,doc: mongodb.FindAndModifyWriteOpResultObject<EnforceDocument<T, TMethods>>,res: any)=>void): QueryWithHelpers<mongodb.FindAndModifyWriteOpResultObject<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;findByIdAndUpdate(id: mongodb.ObjectId | any,update: UpdateQuery<T>| UpdateWithAggregationPipeline,options: QueryOptions &{upsert:true}& ReturnsNewDoc, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;findByIdAndUpdate(id: mongodb.ObjectId | any,update: UpdateQuery<T>| UpdateWithAggregationPipeline, callback?:(err: CallbackError,doc:T|null,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;findByIdAndUpdate(id?: mongodb.ObjectId | any, update?: UpdateQuery<T>| UpdateWithAggregationPipeline, options?: QueryOptions |null, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>|null,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */findOneAndDelete(filter?: FilterQuery<T>, options?: QueryOptions |null, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>|null,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */findOneAndRemove(filter?: FilterQuery<T>, options?: QueryOptions |null, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>|null,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */findOneAndReplace(filter: FilterQuery<T>,replacement: DocumentDefinition<T>| AnyObject,options: QueryOptions &{upsert:true}& ReturnsNewDoc, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;findOneAndReplace(filter?: FilterQuery<T>, replacement?: DocumentDefinition<T>| AnyObject, options?: QueryOptions |null, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>|null,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */findOneAndUpdate(filter: FilterQuery<T>,update: UpdateQuery<T>| UpdateWithAggregationPipeline,options: QueryOptions &{rawResult:true}, callback?:(err: CallbackError,doc: mongodb.FindAndModifyWriteOpResultObject<EnforceDocument<T, TMethods>>,res: any)=>void): QueryWithHelpers<mongodb.FindAndModifyWriteOpResultObject<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;findOneAndUpdate(filter: FilterQuery<T>,update: UpdateQuery<T>| UpdateWithAggregationPipeline,options: QueryOptions &{upsert:true}& ReturnsNewDoc, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;findOneAndUpdate(filter?: FilterQuery<T>, update?: UpdateQuery<T>| UpdateWithAggregationPipeline, options?: QueryOptions |null, callback?:(err: CallbackError,doc: EnforceDocument<T, TMethods>|null,res: any)=>void): QueryWithHelpers<EnforceDocument<T, TMethods>|null, EnforceDocument<T, TMethods>, TQueryHelpers,T>;geoSearch(filter?: FilterQuery<T>, options?: GeoSearchOptions, callback?: Callback<Array<EnforceDocument<T, TMethods>>>): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Executes a mapReduce command. */
mapReduce<Key, Value>(o: MapReduceOptions<T, Key, Value>,
callback?: Callback
): Promise<any>;remove(filter?: any, callback?: CallbackWithoutResult): QueryWithHelpers<any, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */replaceOne(filter?: FilterQuery<T>, replacement?: DocumentDefinition<T>, options?: QueryOptions |null, callback?: Callback): QueryWithHelpers<any, EnforceDocument<T, TMethods>, TQueryHelpers,T>;replaceOne(filter?: FilterQuery<T>, replacement?: Object, options?: QueryOptions |null, callback?: Callback): QueryWithHelpers<any, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Schema the model uses. */schema: Schema;/**
* @deprecated use `updateOne` or `updateMany` instead.
* Creates a `update` query: updates one or many documents that match `filter` with `update`, based on the `multi` option.
*/update(filter?: FilterQuery<T>, update?: UpdateQuery<T>| UpdateWithAggregationPipeline, options?: QueryOptions |null, callback?: Callback): QueryWithHelpers<UpdateWriteOpResult, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `updateMany` query: updates all documents that match `filter` with `update`. */updateMany(filter?: FilterQuery<T>, update?: UpdateQuery<T>| UpdateWithAggregationPipeline, options?: QueryOptions |null, callback?: Callback): QueryWithHelpers<UpdateWriteOpResult, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */updateOne(filter?: FilterQuery<T>, update?: UpdateQuery<T>| UpdateWithAggregationPipeline, options?: QueryOptions |null, callback?: Callback): QueryWithHelpers<UpdateWriteOpResult, EnforceDocument<T, TMethods>, TQueryHelpers,T>;/** Creates a Query, applies the passed conditions, and returns the Query. */where(path: string, val?: any): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;where(obj: object): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;where(): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers,T>;}