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

@filepounder/mongo-magic

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@filepounder/mongo-magic - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

10

lib/MongoQuery.js

@@ -7,3 +7,3 @@ const $merge = require('deepmerge');

const oDataParser = require('./oDataParser.js');
const utils=require('./utils.js')
const _defaultLimit = 50;

@@ -61,3 +61,3 @@

if ($check.object(obj[key])&&!$mongo.ObjectID.isValid(obj[key])){
if ($check.object(obj[key])&&!utils.isValidId(obj[key])){
mergeRawQueryRecursive(obj[key], obj, key);

@@ -71,6 +71,4 @@ } else if($check.array(obj[key])){

parent[parentKey] = new Date(obj[key]);
} else if (key === "$objectId"&&$check.string(obj[key])) {
parent[parentKey] = new $mongo.ObjectID(obj[key]);
}else if (key === "$objectId"&&$mongo.ObjectID.isValid(obj[key])) {
parent[parentKey] = obj[key];
} else if (key === "$objectId"&&utils.isValidId(obj[key])) {
parent[parentKey] = utils.parseId(obj[key]);
}

@@ -77,0 +75,0 @@ else if (key === "$int") {

25

lib/utils.js
const ObjectID = require('mongodb').ObjectID;
const $check=require('check-types');

@@ -11,2 +12,7 @@ class Utils{

}
if ($check.object(id)&&id._bsontype==="ObjectID"&&Buffer.isBuffer(id.id)&&id.id.length===12){
return ObjectID.isValid(id.id);
}
if (id.toString().length !== 24) {

@@ -18,8 +24,21 @@ return false;

}
static parseId (id) {
if (Utils.isValidId(id)) {
return new ObjectID(id.toString());
} else {
if (!id) {
return false;
}
if ($check.object(id)&&id._bsontype==="ObjectID"&&Buffer.isBuffer(id.id)&&id.id.length===12){
return new ObjectID(id.id);
}
if (id.toString().length !== 24) {
return null;
}
if (ObjectID.isValid(id.toString())){
return new ObjectID(id.toString());
}
}

@@ -26,0 +45,0 @@ }

{
"name": "@filepounder/mongo-magic",
"version": "0.2.2",
"version": "0.2.3",
"description": "mongo magic utils",

@@ -5,0 +5,0 @@ "main": "index.js",

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