Add force close Connection#close variant

Connection#close can take a boolean argument `force`. This change goes back
all the way to v4.11.14 (f9e0525fa2f7c8e254f3f949cab6273469b3df30).
This commit is contained in:
Joona Heikkilä
2018-05-23 18:04:38 +03:00
parent c6549e8ac9
commit a6cdf1200d
2 changed files with 7 additions and 1 deletions

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.

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();