mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 19:59:02 +08:00
Mongoose model init (#25530)
* Adding init method declaration on Model interface * Test init method on Model
This commit is contained in:
10
types/mongoose/index.d.ts
vendored
10
types/mongoose/index.d.ts
vendored
@@ -2714,6 +2714,16 @@ declare module "mongoose" {
|
||||
insertMany(doc: any, callback?: (error: any, doc: T) => void): Promise<T>;
|
||||
insertMany(doc: any, options?: { ordered?: boolean, rawResult?: boolean }, callback?: (error: any, doc: T) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Performs any async initialization of this model against MongoDB.
|
||||
* This function is called automatically, so you don't need to call it.
|
||||
* This function is also idempotent, so you may call it to get back a promise
|
||||
* that will resolve when your indexes are finished building as an alternative
|
||||
* to `MyModel.on('index')`
|
||||
* @param callback optional
|
||||
*/
|
||||
init(callback?: (err: any) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Executes a mapReduce command.
|
||||
* @param o an object specifying map-reduce options
|
||||
|
||||
@@ -1420,6 +1420,7 @@ var MongoModel = mongoose.model('MongoModel', new mongoose.Schema({
|
||||
required: true
|
||||
}
|
||||
}), 'myCollection', true);
|
||||
MongoModel.init().then(cb);
|
||||
MongoModel.find({}).$where('indexOf("val") !== -1').exec(function (err, docs) {
|
||||
docs[0].save();
|
||||
docs[0].__v;
|
||||
|
||||
Reference in New Issue
Block a user