diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index ac01ba61bf..a56e14a086 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -2989,6 +2989,12 @@ declare module "mongoose" { create(...docs: any[]): Promise; create(...docsWithCallback: any[]): 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.CollectionCreateOptions, cb?: (err: any) => void): Promise; + /** * Adds a discriminator type. * @param name discriminator model name diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 6eda6d5eb0..5f2dd1bbc6 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -1648,6 +1648,9 @@ MongoModel.create([{ type: 'jelly bean' }, { arg[0].save(); arg[1].save(); }); +MongoModel.createCollection().then(() => {}); +MongoModel.createCollection({ capped: true, max: 42 }).then(() => {}); +MongoModel.createCollection({ capped: true, max: 42 }, err => {}); MongoModel.distinct('url', { clicks: {$gt: 100}}, function (err, result) { }); MongoModel.distinct('url').exec(cb);