From 275df0b0079e910a58c0b7064b83c8427da00301 Mon Sep 17 00:00:00 2001 From: Alexander Chereshnev Date: Mon, 17 Dec 2018 16:25:28 +0300 Subject: [PATCH] Replaced deprecated count() method --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 8af68dd..7a07e4f 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,7 @@ function paginate(query, options, callback) { } promises = { docs: docsQuery.exec(), - count: this.count(query).exec() + count: this.countDocuments(query).exec() }; if (lean && leanWithId) { promises.docs = promises.docs.then((docs) => { @@ -66,7 +66,7 @@ function paginate(query, options, callback) { return Promise.all(promises).then((data) => { let result = { docs: data.docs, - total: data.count, + total: data.countDocuments, limit: limit }; if (offset !== undefined) { @@ -74,7 +74,7 @@ function paginate(query, options, callback) { } if (page !== undefined) { result.page = page; - result.pages = Math.ceil(data.count / limit) || 1; + result.pages = Math.ceil(data.countDocuments / limit) || 1; } if (typeof callback === 'function') { return callback(null, result);