diff --git a/mongoose_resource.js b/mongoose_resource.js index ff52dc2..6a6bab3 100644 --- a/mongoose_resource.js +++ b/mongoose_resource.js @@ -90,9 +90,9 @@ var MongooseResource = module.exports = Resource.extend({ if(self.model.schema.paths[query_key]) { if(self.model.schema.paths[query_key].options.type == Boolean) - query_value = query_value.toLowerCase().trim() == 'true'; + query_value = typeof(query_value) == 'string' ? query_value.toLowerCase().trim() == 'true' : !!query_value; if(self.model.schema.paths[query_key].options.type == Number) - query_value = Number(query_value.trim()); + query_value = typeof(query_value) == 'string' ? Number(query_value.trim()) : Number(query_value); } if(query_op) { diff --git a/package.json b/package.json index c2658d6..06023da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jest", "description": "JavaScriptational State Transfer. JS restful API layer with Mongoose based resources. Inspired by python Tastypie", - "version": "0.1.38", + "version": "0.1.40", "author": "Ishai Jaffe ", "contributors": [ { diff --git a/resource.js b/resource.js index 69e5c4b..d144878 100644 --- a/resource.js +++ b/resource.js @@ -835,10 +835,8 @@ var Resource = module.exports = Class.extend({ } return objects; } - if (typeof(object) != 'object') + if (typeof(object) != 'object' || object === null) return object; -// if (!tree) -// return object; var new_object = {}; var tree_empty = tree ? true : false; var exclude_tree_empty = exclude_tree ? true : false;