{"action":"created","issue":{"url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose/issues/285","repository_url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose","labels_url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose/issues/285/labels{/name}","comments_url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose/issues/285/comments","events_url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose/issues/285/events","html_url":"https://github.com/florianholzapfel/express-restify-mongoose/issues/285","id":149934159,"number":285,"title":"jsonQueryParser inaccurate parse value in JSON when value[0] is '!','<','>'...","user":{"login":"johnzhou2011","id":6656559,"avatar_url":"https://avatars.githubusercontent.com/u/6656559?v=3","gravatar_id":"","url":"https://api.github.com/users/johnzhou2011","html_url":"https://github.com/johnzhou2011","followers_url":"https://api.github.com/users/johnzhou2011/followers","following_url":"https://api.github.com/users/johnzhou2011/following{/other_user}","gists_url":"https://api.github.com/users/johnzhou2011/gists{/gist_id}","starred_url":"https://api.github.com/users/johnzhou2011/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnzhou2011/subscriptions","organizations_url":"https://api.github.com/users/johnzhou2011/orgs","repos_url":"https://api.github.com/users/johnzhou2011/repos","events_url":"https://api.github.com/users/johnzhou2011/events{/privacy}","received_events_url":"https://api.github.com/users/johnzhou2011/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose/labels/enhancement","name":"enhancement","color":"5EBEFF"},{"url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose/labels/v5.0","name":"v5.0","color":"000000"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-04-21T01:40:00Z","updated_at":"2016-08-22T14:48:00Z","closed_at":null,"body":"The jsonQueryParser should parser the key not value[0]\r\neg: \r\n`{messageId: \"70666280047D7CD@front04.ibpmail.net\\>A(addedAbyApostmaster@ibpmail.com)\"}`\r\nwill convert to\r\n`Mongoose: emails.find({\"messageId\":{\"$lt\":\"570666280047D7CD@front04.ibpmail.net>A(addedAbyApostmaster@ibpmail.com)\"}})`\r\nnot\r\n`Mongoose: \r\nemails.find({\"messageId\": \"<570666280047D7CD@front04.ibpmail.net>A(addedAbyApostmaster@ibpmail.com)\"})`\r\n\r\nWe need recursive parse keys to operators , currently jsonQueryParser is needless, all JSON should accrate to provide operators such as \"$lt\" as a key in JSON string.\r\n\r\n```\r\n// H+ - JSON query param parser\r\n  // TODO - improve to serve recursive logical operators\r\n  function jsonQueryParser (key, value) {\r\n    if (_.isString(value)) {\r\n      if (value[0] === '~') { // parse RegExp\r\n        return new RegExp(value.substring(1), 'i')\r\n      } else if (value[0] === '>') {\r\n        if (value[1] === '=') {\r\n          return {$gte: value.substr(2)}\r\n        } else {\r\n          return {$gt: value.substr(1)}\r\n        }\r\n      } else if (value[0] === '<') {\r\n        if (value[1] === '=') {\r\n          return {$lte: value.substr(2)}\r\n        } else {\r\n          return {$lt: value.substr(1)}\r\n        }\r\n      } else if (value[0] === '!' && value[1] === '=') {\r\n        return {$ne: value.substr(2)}\r\n      } else if (value[0] === '=') {\r\n        return {$eq: value.substring(1)}\r\n      }\r\n    } else if (_.isArray(value)) {\r\n      if (model.schema.paths.hasOwnProperty(key)) {\r\n        return {$in: value}\r\n      }\r\n    }\r\n    return value\r\n  }\r\n```"},"comment":{"url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose/issues/comments/241436984","html_url":"https://github.com/florianholzapfel/express-restify-mongoose/issues/285#issuecomment-241436984","issue_url":"https://api.github.com/repos/florianholzapfel/express-restify-mongoose/issues/285","id":241436984,"user":{"login":"Zertz","id":2636763,"avatar_url":"https://avatars.githubusercontent.com/u/2636763?v=3","gravatar_id":"","url":"https://api.github.com/users/Zertz","html_url":"https://github.com/Zertz","followers_url":"https://api.github.com/users/Zertz/followers","following_url":"https://api.github.com/users/Zertz/following{/other_user}","gists_url":"https://api.github.com/users/Zertz/gists{/gist_id}","starred_url":"https://api.github.com/users/Zertz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zertz/subscriptions","organizations_url":"https://api.github.com/users/Zertz/orgs","repos_url":"https://api.github.com/users/Zertz/repos","events_url":"https://api.github.com/users/Zertz/events{/privacy}","received_events_url":"https://api.github.com/users/Zertz/received_events","type":"User","site_admin":false},"created_at":"2016-08-22T14:48:00Z","updated_at":"2016-08-22T14:48:00Z","body":"I'm not sure how useful this is so it could probably be removed for 5.0 and @johnzhou2011 raised a good point, running a query like `\"name\": \"<Zertz\"` will, in most cases, match pretty much the entire collection. Of course, we have a default limit in place, but it's still awkward (impossible?) to query for the actual `<` character.\r\n\r\n@florianholzapfel Thoughts?"}}
{"actor":{"display_login":"Zertz"}}