From a6cdf1200d91a1f9631662e210dcc7761d5490f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joona=20Heikkil=C3=A4?= Date: Wed, 23 May 2018 18:04:38 +0300 Subject: [PATCH] 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). --- types/mongoose/index.d.ts | 3 +++ types/mongoose/mongoose-tests.ts | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index a28bfc6d84..310417089f 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -236,6 +236,9 @@ declare module "mongoose" { /** Closes the connection */ close(callback?: (err: any) => void): Promise; + /** Closes the connection */ + close(force?: boolean, callback?: (err: any) => void): Promise; + /** * Retrieves a collection, creating it if not cached. * Not typically needed by applications. Just talk to your collection through your model. diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index df4762c488..a43c690572 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -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();