{"action":"created","issue":{"url":"https://api.github.com/repos/fresheneesz/mongo-parse/issues/4","repository_url":"https://api.github.com/repos/fresheneesz/mongo-parse","labels_url":"https://api.github.com/repos/fresheneesz/mongo-parse/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/fresheneesz/mongo-parse/issues/4/comments","events_url":"https://api.github.com/repos/fresheneesz/mongo-parse/issues/4/events","html_url":"https://github.com/fresheneesz/mongo-parse/issues/4","id":139111149,"number":4,"title":"$in operator","user":{"login":"platdesign","id":4584887,"avatar_url":"https://avatars.githubusercontent.com/u/4584887?v=3","gravatar_id":"","url":"https://api.github.com/users/platdesign","html_url":"https://github.com/platdesign","followers_url":"https://api.github.com/users/platdesign/followers","following_url":"https://api.github.com/users/platdesign/following{/other_user}","gists_url":"https://api.github.com/users/platdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/platdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/platdesign/subscriptions","organizations_url":"https://api.github.com/users/platdesign/orgs","repos_url":"https://api.github.com/users/platdesign/repos","events_url":"https://api.github.com/users/platdesign/events{/privacy}","received_events_url":"https://api.github.com/users/platdesign/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-07T22:15:10Z","updated_at":"2016-03-08T02:03:02Z","closed_at":null,"body":"Hey, nice work!\r\n\r\nI tried to match a collection of docs having a schema like:\r\n\r\n```javascript\r\n{\r\n\t_id:123,\r\n\ttags: ['a','b','c']\r\n}\r\n```\r\n\r\n... with following query:\r\n\r\n```javascript\r\n{\r\n\ttags: { $in:['a','b'] }\r\n}\r\n```\r\n\r\n... but got no results.\r\n\r\n\r\nThe mongoDB-Docs of `$in` say:\r\n\r\n> If the field holds an array, then the $in operator selects the documents whose field holds an array that contains at least one element that matches a value in the specified array [...].\r\n\r\n\r\nLooked at your implementation and found, that it only can match 'single' values.\r\n\r\n```javascript\r\n// matches.js\r\n$in:function(docVal,operand) {\r\n\treturn operand.indexOf(docVal) !== -1\r\n}\r\n```\r\n\r\nSuggestion for an implementation of the mongoDB behavior:\r\n\r\n```javascript\r\n$in:function(docVal,operand) {\r\n\tif(Array.isArray(docVal)) {\r\n\t\treturn docVal.some(function(val) {\r\n\t\t\treturn operand.indexOf(val) !== -1;\r\n\t\t});\r\n\t} else {\r\n\t\treturn operand.indexOf(docVal) !== -1\r\n\t}\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/fresheneesz/mongo-parse/issues/comments/193554131","html_url":"https://github.com/fresheneesz/mongo-parse/issues/4#issuecomment-193554131","issue_url":"https://api.github.com/repos/fresheneesz/mongo-parse/issues/4","id":193554131,"user":{"login":"fresheneesz","id":149531,"avatar_url":"https://avatars.githubusercontent.com/u/149531?v=3","gravatar_id":"","url":"https://api.github.com/users/fresheneesz","html_url":"https://github.com/fresheneesz","followers_url":"https://api.github.com/users/fresheneesz/followers","following_url":"https://api.github.com/users/fresheneesz/following{/other_user}","gists_url":"https://api.github.com/users/fresheneesz/gists{/gist_id}","starred_url":"https://api.github.com/users/fresheneesz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fresheneesz/subscriptions","organizations_url":"https://api.github.com/users/fresheneesz/orgs","repos_url":"https://api.github.com/users/fresheneesz/repos","events_url":"https://api.github.com/users/fresheneesz/events{/privacy}","received_events_url":"https://api.github.com/users/fresheneesz/received_events","type":"User","site_admin":false},"created_at":"2016-03-08T02:03:02Z","updated_at":"2016-03-08T02:03:02Z","body":"Thanks! Mind creating a pull request for that? A unit test would be nice too."}}