resource-schema
Advanced tools
Comparing version 0.17.1 to 0.17.2
// Generated by CoffeeScript 1.9.2 | ||
var ObjectId, RESERVED_KEYWORDS, ResourceSchema, _, boom, deepExtend, dot, err, q, | ||
var ObjectId, ResourceSchema, _, boom, deepExtend, dot, err, keyChecker, q, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
@@ -25,3 +25,3 @@ slice = [].slice, | ||
RESERVED_KEYWORDS = require('./reserved_keywords'); | ||
keyChecker = require('./key_checker'); | ||
@@ -757,7 +757,14 @@ module.exports = ResourceSchema = (function() { | ||
Collapse all nested fields to dot format. Ignore Reserved Keywords on schema. | ||
@param {Object} obj - object to convert to dot strings | ||
@param {Function} [shouldIgnore] - optional function to check if you should ignore the key for dot stringifying | ||
@example {a: {b: 1}} -> {'a.b': 1} | ||
*/ | ||
ResourceSchema.prototype._convertKeysToDotStrings = function(obj) { | ||
ResourceSchema.prototype._convertKeysToDotStrings = function(obj, shouldIgnore) { | ||
var dotKeys, dotStringify; | ||
if (shouldIgnore == null) { | ||
shouldIgnore = function() { | ||
return false; | ||
}; | ||
} | ||
dotKeys = {}; | ||
@@ -770,3 +777,3 @@ dotStringify = function(obj, current) { | ||
newKey = current ? current + "." + key : key; | ||
if (indexOf.call(RESERVED_KEYWORDS, key) >= 0) { | ||
if (shouldIgnore(key, value)) { | ||
if (dotKeys[current] == null) { | ||
@@ -840,3 +847,3 @@ dotKeys[current] = {}; | ||
var config, key, normalizedSchema; | ||
schema = this._convertKeysToDotStrings(schema); | ||
schema = this._convertKeysToDotStrings(schema, keyChecker.isReserved); | ||
normalizedSchema = {}; | ||
@@ -843,0 +850,0 @@ for (key in schema) { |
{ | ||
"name": "resource-schema", | ||
"version": "0.17.1", | ||
"version": "0.17.2", | ||
"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
90277
14
1230