Add Model.createCollection() (#34193)

This commit is contained in:
ulrichb
2019-03-25 13:44:15 -07:00
committed by Ron Buckton
parent dfc313721a
commit 8d45b2e1be
2 changed files with 9 additions and 0 deletions
+6
View File
@@ -2989,6 +2989,12 @@ declare module "mongoose" {
create(...docs: any[]): Promise<T>;
create(...docsWithCallback: any[]): Promise<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.
*/
createCollection(options?: mongodb.CollectionCreateOptions, cb?: (err: any) => void): Promise<void>;
/**
* Adds a discriminator type.
* @param name discriminator model name
+3
View File
@@ -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);