Skip to content

Commit

Permalink
null on fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ishai committed May 20, 2015
1 parent 1a010d1 commit f95292c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mongoose_resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"contributors": [
{
Expand Down
4 changes: 1 addition & 3 deletions resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f95292c

Please sign in to comment.