resource-schema
Advanced tools
Comparing version 1.1.0 to 1.2.0
// Generated by CoffeeScript 1.10.0 | ||
/* | ||
Extends two levels deep, so that we can extend query configuration objects without overwritting previous queries for the same property | ||
* deep extend so that we can add multiple queries to any given property | ||
Extends in such a way that we can merge query configuration objects without | ||
clobbering any queries for the same property - when in doubt, `AND` the queries. | ||
* e.g. {'day': $gt: '2014-10-1'}, {day: $lt: '2014-11-1'} => | ||
* {'day': $gt: '2014-10-1', $lt: '2014-11-1'} | ||
* {'day': $and: [{$gt: '2014-10-1'}, {$lt: '2014-11-1'}]} | ||
*/ | ||
module.exports = function(obj, obj2) { | ||
var config, key, newKey, newValue; | ||
var config, key, obj1, obj3, ref; | ||
for (key in obj2) { | ||
config = obj2[key]; | ||
if ((obj[key] != null) && typeof config === 'object') { | ||
for (newKey in config) { | ||
newValue = config[newKey]; | ||
obj[key][newKey] = newValue; | ||
if (obj[key] != null) { | ||
if (key !== '$and') { | ||
obj.$and = [ | ||
( | ||
obj1 = {}, | ||
obj1["" + key] = config, | ||
obj1 | ||
), ( | ||
obj3 = {}, | ||
obj3["" + key] = obj[key], | ||
obj3 | ||
) | ||
]; | ||
delete obj[key]; | ||
} else { | ||
(ref = obj.$and).push.apply(ref, config); | ||
} | ||
@@ -18,0 +30,0 @@ } else { |
{ | ||
"name": "resource-schema", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Define schemas for RESTful resources from mongoose models, and generate middleware to GET, POST, PUT, and DELETE to those resources.", | ||
@@ -5,0 +5,0 @@ "author": "Good Eggs <open-source@goodeggs.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1305
125111
14