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

mongolass

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongolass - npm Package Compare versions

Comparing version 4.2.1 to 4.3.0

4

changelog.md

@@ -0,1 +1,5 @@

## 4.3.0/2018-05-21
- fix: `_formatSetOrSetOnInsert`
## 4.2.1/2018-05-14

@@ -2,0 +6,0 @@

46

lib/schema.js

@@ -338,8 +338,9 @@ const _ = require('lodash')

function _formatSetOrSetOnInsert (doc, schemaPath = '', parentDoc, parentKey) {
if (_.isPlainObject(doc)) {
function _formatSetOrSetOnInsert (doc, schemaPath = '', parentDoc, parentKey, subSchema = compiledSchema) {
if (_.isPlainObject(doc) && !subSchema._leaf) {
for (let key in doc) {
const subDoc = doc[key]
const subSchemaPath = `${schemaPath ? schemaPath + '.' : ''}${key}`
doc[key] = _formatSetOrSetOnInsert(subDoc, subSchemaPath, doc, key)
const subSchema = getSchema(compiledSchema, subSchemaPath)
doc[key] = _formatSetOrSetOnInsert(subDoc, subSchemaPath, doc, key, subSchema)
}

@@ -349,24 +350,21 @@ } else {

// only leaf & only check type & ignoreNodeType
/* istanbul ignore else */
if (schema._leaf) {
// try format, if false then pass
if (_.isArray(doc)) {
const result = schema.validate(doc)
if (!result.valid) {
throw result.error
}
doc = result.result
} else {
// eg: 'posts.comments' -> 'comments'
let key = parentKey.split('.').slice(-1)[0]
const result = schema._parent.validate({ [key]: doc }, {
ignoreNodeType: true,
required: false,
default: false
})
if (!result.valid) {
throw result.error
}
doc = result.result[key]
// try format, if false then pass
if (_.isArray(doc)) {
const result = schema.validate(doc)
if (!result.valid) {
throw result.error
}
doc = result.result
} else {
// eg: 'posts.comments' -> 'comments'
let key = parentKey.split('.').slice(-1)[0]
const result = schema._parent.validate({ [key]: doc }, {
ignoreNodeType: true,
required: false,
default: false
})
if (!result.valid) {
throw result.error
}
doc = result.result[key]
}

@@ -373,0 +371,0 @@ }

{
"name": "mongolass",
"version": "4.2.1",
"version": "4.3.0",
"description": "Elegant MongoDB driver for Node.js.",

@@ -5,0 +5,0 @@ "main": "lib/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