@vmm/service
Advanced tools
Comparing version 1.0.68 to 1.0.69
{ | ||
"name": "@vmm/service", | ||
"version": "1.0.68", | ||
"version": "1.0.69", | ||
"main": "src/index.js", | ||
@@ -5,0 +5,0 @@ "description": "VMM Service library", |
@@ -9,2 +9,3 @@ "use strict"; | ||
const logger_1 = require("./logger"); | ||
const mongodb_1 = require("mongodb"); | ||
const log = logger_1.logger(`@vmm/service:restDbApi`); | ||
@@ -38,3 +39,3 @@ function _mergeExcludeFields(reqOptions, excludeFields) { | ||
if (m && m.length === 2) { | ||
obj[k] = callback(m[1]); | ||
obj[k] = callback(m[1], k); | ||
} | ||
@@ -47,3 +48,3 @@ } | ||
} | ||
function _sessionMatch(query, sessionMatch, sessions) { | ||
function _buildQuery(query, sessionMatch, sessions) { | ||
let retQuery = query; | ||
@@ -59,2 +60,5 @@ if (lodash_1.default.isPlainObject(sessionMatch)) { | ||
} | ||
_eachValueDeep(retQuery, /^object\(.+\)$/i, (value) => { | ||
return new mongodb_1.ObjectId(value); | ||
}); | ||
return retQuery; | ||
@@ -72,3 +76,3 @@ } | ||
log.debug('findOne -- options:', options); | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
return await db.findOne(query, options); | ||
@@ -82,3 +86,3 @@ }, | ||
log.debug('find -- options:', options); | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -91,3 +95,3 @@ return await db.find(query, options).toArray(); | ||
log.debug('countDocuments:', collName, req, sessions, _restOptions); | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -100,3 +104,3 @@ return await db.countDocuments(query, req.options); | ||
log.debug('estimatedDocumentCount:', collName, req, sessions, _restOptions); | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -109,3 +113,3 @@ return await db.estimatedDocumentCount(query, req.options); | ||
log.debug('geoHaystackSearch:', collName, req, sessions, _restOptions); | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -126,3 +130,3 @@ return await db.geoHaystackSearch(req.x, req.y, req.options); | ||
log.debug('distinct:', collName, req, sessions, _restOptions); | ||
let query = _sessionMatch(req.query, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.query, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -141,3 +145,3 @@ return await db.distinct(req.key, query); | ||
const db = mongo.collections()[collName]; | ||
log.debug('insertOne:', collName, req, sessions, _restOptions); | ||
log.debug('insertMany:', collName, req, sessions, _restOptions); | ||
let docs = req.docs; | ||
@@ -156,3 +160,3 @@ return await db.insertMany(docs); | ||
} | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -174,3 +178,3 @@ log.debug('update:----', update); | ||
} | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -192,3 +196,3 @@ log.debug('update:----', update); | ||
} | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -210,3 +214,3 @@ log.debug('update:----', update); | ||
} | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -222,3 +226,3 @@ log.debug('update:----', replacement); | ||
log.debug('deleteOne:', collName, req, sessions, _restOptions); | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
const options = (req.options || {}); | ||
@@ -233,3 +237,3 @@ log.debug('query:----', query); | ||
log.debug('deleteOne:', collName, req, sessions, _restOptions); | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
const options = (req.options || {}); | ||
@@ -245,3 +249,3 @@ log.debug('query:----', query); | ||
const options = _mergeExcludeFields(req.options, _restOptions.excludeFields); | ||
let query = _sessionMatch(req.filter, _restOptions.sessionMatch, sessions); | ||
let query = _buildQuery(req.filter, _restOptions.sessionMatch, sessions); | ||
log.debug('query:----', query); | ||
@@ -248,0 +252,0 @@ const ret = await db.findOneAndDelete(query, options); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
45338
1140
1