Socket
Socket
Sign inDemoInstall

modm

Package Overview
Dependencies
219
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

15

lib/adapter.js

@@ -110,6 +110,15 @@ var valify = require('./manipulator');

if (typeof result[2][field] === 'undefined' && self._schema.paths[field]) {
var value = defaultValue(self._schema.paths[field].type, self._schema.default[field]);
// handle default value errors
if (value.constructor.name === 'Error') {
return callback(value);
}
// add default value to document
if (method !== 'insert') {
result[1].$set[field] = defaultValue(self._schema.paths[field].type, self._schema.default[field]);
result[1].$set[field] = value;
} else {
result[1][field] = defaultValue(self._schema.paths[field].type, self._schema.default[field]);
result[1][field] = value;
}

@@ -129,3 +138,3 @@ }

}
args[docIndex] = result[1];

@@ -132,0 +141,0 @@ }

12

lib/convert.js

@@ -41,5 +41,15 @@ var ObjectId = require('pongo').ObjectId;

return value;
}
}
if (value && value.constructor.name !== 'Date' && type === 'date') {
value = new Date(value);
if (isNaN(value.valueOf())) {
return new Error('Date conversion failed:');
}
return value;
}
return value;

@@ -46,0 +56,0 @@ }

@@ -0,1 +1,3 @@

var convert = require('./convert');
// handle special default values

@@ -12,9 +14,10 @@ var types = {

// TODO handle validation
function handleValue (type, value) {
if (types[type]) {
return types[type](value);
value = types[type](value);
}
return value;
return convert(type, value);
}

@@ -21,0 +24,0 @@

@@ -64,3 +64,3 @@ // INFO: results of atomic operations are not validated.

// convert objectid
// convert type
value = convert(options.type, value);

@@ -67,0 +67,0 @@ if (value.constructor.name === 'Error') {

@@ -34,3 +34,3 @@ // validate a data types

}
return data.constructor.name === "Date" ? true : false;

@@ -37,0 +37,0 @@ };

{
"name": "modm",
"version": "0.2.0",
"version": "0.2.1",
"author": "Adrian Ottiker <adrian@ottiker.com>",

@@ -5,0 +5,0 @@ "description": "A MongoDB Object Document Mapper (ODM)",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc