@synatic/mongo-magic
Advanced tools
Comparing version 2.2.0 to 2.3.0
/* eslint-disable valid-jsdoc */ | ||
const {callbackify} = require('node:util'); | ||
const $moment = require('moment'); | ||
@@ -73,12 +74,15 @@ const $check = require('check-types'); | ||
const filter = query.parsedQuery.query || {}; | ||
this._collection | ||
.countDocuments(filter, options) | ||
.then((count) => { | ||
if (!count) { | ||
return callback(null, 0); | ||
} | ||
callbackify(() => { | ||
return this._collection.countDocuments(filter, options); | ||
})((err, count) => { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return callback(null, count); | ||
}) | ||
.catch(callback); | ||
if (!count) { | ||
return callback(null, 0); | ||
} | ||
return callback(null, count); | ||
}); | ||
} | ||
@@ -147,15 +151,14 @@ | ||
try { | ||
const cursor = this.queryAsCursor(query, options); | ||
callbackify(() => { | ||
return this.queryAsCursor(query, options).toArray(); | ||
})((err, results) => { | ||
if (err) { | ||
return callback(err); | ||
} | ||
cursor | ||
.toArray() | ||
.then((results) => { | ||
if (!results) { | ||
return callback(null, []); | ||
} | ||
return callback(null, results); | ||
}) | ||
.catch((err) => { | ||
return callback(err); | ||
}); | ||
if (!results) { | ||
return callback(null, []); | ||
} | ||
return callback(null, results); | ||
}); | ||
} catch (exp) { | ||
@@ -230,8 +233,11 @@ return callback(exp); | ||
} | ||
this._collection | ||
.updateOne(options.query, update) | ||
.then((result) => { | ||
return callback(null, result); | ||
}) | ||
.catch(callback); | ||
callbackify(() => { | ||
return this._collection.updateOne(options.query, update); | ||
})((err, result) => { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return callback(null, result); | ||
}); | ||
} | ||
@@ -238,0 +244,0 @@ |
{ | ||
"name": "@synatic/mongo-magic", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Synatic utility classes for interacting with MongoDB", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36029
884