From efdc88d952458dc323c1ccf7b7efb1367f26f061 Mon Sep 17 00:00:00 2001 From: Birm Date: Tue, 23 Apr 2024 18:29:57 -0400 Subject: [PATCH] add count as handler --- handlers/dataHandlers.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/handlers/dataHandlers.js b/handlers/dataHandlers.js index e0c585f..b345aaf 100644 --- a/handlers/dataHandlers.js +++ b/handlers/dataHandlers.js @@ -13,6 +13,16 @@ General.find = function(db, collection) { }; }; +General.count = function(db, collection) { + return function(req, res, next) { + var query = req.query; + mongoDB.count(db, collection, query).then((x) => { + req.data = x; + next(); + }).catch((e) => next(e)); + }; +}; + General.findWithRegex = function(db, collection) { return function(req, res, next) { var query = req.query;