Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@synatic/mongo-magic

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@synatic/mongo-magic - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

56

lib/MongoQuery.js

@@ -104,2 +104,58 @@ const $merge = require('deepmerge');

}
/** Merges mongo queries
*
* @param {string|object} fromQuery - the query to merge from
* @param {string|object} toQuery - the query to merge into
* @param {string} [type] - the type of merge, and/or. default is and
* @returns {{$and: [any, *]}|{$and}|*|null}
*/
static mergeQuery(fromQuery, toQuery, type) {
if (!fromQuery && !toQuery) {
return null;
} else if (!fromQuery) {
return toQuery;
} else if (!toQuery) {
return fromQuery;
}
if (!$check.object(fromQuery)) {
try {
fromQuery = JSON.parse(fromQuery);
} catch (exp) {
throw new Error("Invalid To Query String")
}
}
if (!$check.object(toQuery)) {
try {
fromQuery = JSON.parse(toQuery);
} catch (exp) {
throw new Error("Invalid To Query String")
}
}
if (type !== "or") {
if (toQuery.$and) {
toQuery.$and.push(fromQuery);
return toQuery;
} else {
return {
$and: [
fromQuery,
toQuery
]
}
}
} else {
return {
$or: [
fromQuery,
toQuery
]
}
}
}
}

@@ -106,0 +162,0 @@

4

package.json
{
"name": "@synatic/mongo-magic",
"version": "0.2.5",
"version": "0.2.6",
"description": "mongo magic utils",

@@ -44,3 +44,3 @@ "main": "index.js",

"moment": "2.24.0",
"mongodb": "3.4.0",
"mongodb": "3.5.9",
"odata-parser": "1.4.1",

@@ -47,0 +47,0 @@ "underscore.string": "3.3.5"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc