Merge pull request #25970 from cxcorp/mongoose-add-close-force-overload

Mongoose: Add force close Connection#close variant
This commit is contained in:
Daniel Rosenwasser
2018-05-26 22:17:17 -07:00
committed by GitHub
2 changed files with 7 additions and 1 deletions
+3
View File
@@ -236,6 +236,9 @@ declare module "mongoose" {
/** Closes the connection */
close(callback?: (err: any) => void): Promise<void>;
/** Closes the connection */
close(force?: boolean, callback?: (err: any) => void): Promise<void>;
/**
* Retrieves a collection, creating it if not cached.
* Not typically needed by applications. Just talk to your collection through your model.
+4 -1
View File
@@ -135,7 +135,10 @@ conn1.openUri('mongodb://localhost/test', 'myDb', 27017, {
autoIndex: false
}
}, function (err) {}).open('');
conn1.close().catch(function (err) {});
conn1.close().then(function () {}).catch(function (err) {});
conn1.close(true).then(function () {}).catch(function (err) {});
conn1.close(function (err) {});
conn1.close(true, function (err) {});
conn1.collection('name').$format(999);
conn1.model('myModel', new mongoose.Schema({}), 'myCol').find();
conn1.models.myModel.findOne().exec();