New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-schema-extend

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-schema-extend - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

LICENSE

35

index.js

@@ -9,2 +9,4 @@ 'use strict';

var Reflect = require('harmony-reflect');
/**

@@ -17,9 +19,26 @@ * Add a new function to the schema prototype to create a new schema by extending an existing one

// Fix for callQueue arguments, todo: fix clone implementation
newSchema.callQueue.forEach(function(k) {
var args = [];
for(var i in k[1]) {
args.push(k[1][i]);
newSchema._callQueue = [];
var that = this;
newSchema.callQueue = new Proxy(newSchema._callQueue, {
get: function(target, property, receiver) {
switch (property) {
case 'length':
return target.length + that.callQueue.length;
case 'toJSON':
return () => target.concat(that.callQueue);
case 'push':
return (e) => target.push(e);
break;
case 'reduce':
return Array.prototype.reduce.bind(target.concat(that.callQueue));
default:
if(isNaN(property)) {
return target[property];
} else {
return that.callQueue.concat(target)[property];
}
}
}
k[1] = args;
});

@@ -30,4 +49,4 @@

this.paths[k].validators.forEach(function (validator, index) {
if (validator.validator instanceof RegExp) {
newSchema.paths[k].validators[index].validator = validator.validator;
if (validator.regexp instanceof RegExp) {
newSchema.paths[k].validators[index].regexp = validator.regexp;
}

@@ -34,0 +53,0 @@ });

{
"name": "mongoose-schema-extend",
"version": "0.2.0",
"version": "0.2.1",
"description": "mongoose schema inheritance and discriminator key extension",
"main": "index.js",
"scripts": {
"test": "node ./node_modules/.bin/grunt test"
"test": "node --harmony_proxies ./node_modules/.bin/grunt test"
},

@@ -23,9 +23,22 @@ "homepage": "https://github.com/briankircho/mongoose-schema-extend",

"contributors": [
{ "name": "Brian Kirchoff", "email": "briankircho@gmail.com" },
{ "name": "Ajay Sabhaney", "email": "ajay@mothercreative.com" },
{ "name": "Nicholas Calugar", "email" : "njcalugar@gmail.com" },
{ "name": "Luis Sieira", "email" : "luis.sieira@spacebar.fr" }
{
"name": "Brian Kirchoff",
"email": "briankircho@gmail.com"
},
{
"name": "Ajay Sabhaney",
"email": "ajay@mothercreative.com"
},
{
"name": "Nicholas Calugar",
"email": "njcalugar@gmail.com"
},
{
"name": "Luis Sieira",
"email": "luis.sieira@spacebar.fr"
}
],
"license": "BSD-3-Clause",
"license": "MIT",
"dependencies": {
"harmony-reflect": "^1.4.2",
"owl-deepcopy": "~0.0.1"

@@ -32,0 +45,0 @@ },

@@ -62,2 +62,24 @@ 'use strict';

it('Should allow two vehicles of the same brand with different model', function (done) {
var fordSierra = new fixtures.Ford({
year : 1986,
model : 'sierra'
});
var anotherFordSierra = new fixtures.Ford({
year : 2030,
model : 'planet'
});
fordSierra.save(function(err) {
should.not.exist(err);
fordSierra._type.should.equal('ford');
anotherFordSierra.save(function(err) {
should.not.exist(err);
done();
})
});
});
it('Should allow two vehicles of the same obscure brand with the same model', function (done) {

@@ -64,0 +86,0 @@ var fordSierra = new fixtures.Ford({

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