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

mongoose-embedded-document

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-embedded-document - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

49

lib/plugin.js

@@ -1,4 +0,4 @@

// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.10.0
var Schema, mongoose, setPath,
__slice = [].slice;
slice = [].slice;

@@ -10,7 +10,7 @@ mongoose = require('mongoose');

setPath = function(obj, path, value) {
var key, keys, lastKey, _i, _len;
var i, key, keys, lastKey, len;
keys = path.split('.');
lastKey = keys.pop();
for (_i = 0, _len = keys.length; _i < _len; _i++) {
key = keys[_i];
for (i = 0, len = keys.length; i < len; i++) {
key = keys[i];
if (obj[key] == null) {

@@ -42,14 +42,14 @@ obj[key] = {};

setWithEmbedded = function() {
var args, embeddedPath, path, _i, _len, _ref, _results;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
var args, embeddedPath, i, len, path, ref, results;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
setWithoutEmbedded.apply(obj, args);
_ref = obj.modifiedPaths();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
path = _ref[_i];
ref = obj.modifiedPaths();
results = [];
for (i = 0, len = ref.length; i < len; i++) {
path = ref[i];
embeddedPath = [options.path, path].join('.');
parent.setValue(embeddedPath, obj.getValue(path));
_results.push(parent.markModified(embeddedPath));
results.push(parent.markModified(embeddedPath));
}
return _results;
return results;
};

@@ -74,2 +74,5 @@ obj.set = setWithEmbedded;

var modelClass, propertyName;
if (data == null) {
return null;
}
modelClass = mongoose.model(options.ref, false, false);

@@ -93,3 +96,3 @@ propertyName = "" + options.path + modelClass.schema.name;

return function(err) {
var key, value, _ref;
var key, ref, value;
if (err) {

@@ -99,6 +102,6 @@ if (_this.errors == null) {

}
_ref = err.errors;
for (key in _ref) {
value = _ref[key];
_this.errors["" + options.path + "." + key] = value;
ref = err.errors;
for (key in ref) {
value = ref[key];
_this.errors[options.path + "." + key] = value;
}

@@ -124,9 +127,9 @@ }

return schema.method('toJSON', function(options) {
var path, result, _i, _len, _ref, _ref1, _ref2;
var i, len, path, ref, ref1, ref2, result;
result = mongoose.Document.prototype.toJSON.call(this, options);
if (options != null ? options.client : void 0) {
_ref1 = (_ref = schema.__embeddedPaths) != null ? _ref : [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
path = _ref1[_i];
setPath(result, path, (_ref2 = this.get(path)) != null ? _ref2.toJSON(options) : void 0);
ref1 = (ref = schema.__embeddedPaths) != null ? ref : [];
for (i = 0, len = ref1.length; i < len; i++) {
path = ref1[i];
setPath(result, path, (ref2 = this.get(path)) != null ? ref2.toJSON(options) : void 0);
}

@@ -133,0 +136,0 @@ }

{
"name": "mongoose-embedded-document",
"version": "1.0.0",
"version": "1.0.1",
"description": "A Mongoose plugin to provide support for embedding single documents.",

@@ -26,3 +26,3 @@ "author": "Good Eggs <open-source@goodeggs.com>",

"mocha-sinon": "~1.x.x",
"mongoose": "~3.6.17",
"mongoose": "~3.8.19",
"fibrous": "~0.3.3"

@@ -29,0 +29,0 @@ },

Sorry, the diff of this file is not supported yet

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