{"action":"created","issue":{"url":"https://api.github.com/repos/scttnlsn/monq/issues/52","labels_url":"https://api.github.com/repos/scttnlsn/monq/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/scttnlsn/monq/issues/52/comments","events_url":"https://api.github.com/repos/scttnlsn/monq/issues/52/events","html_url":"https://github.com/scttnlsn/monq/pull/52","id":101987337,"number":52,"title":"adding ordination as option","user":{"login":"trsouz","id":1700827,"avatar_url":"https://avatars.githubusercontent.com/u/1700827?v=3","gravatar_id":"","url":"https://api.github.com/users/trsouz","html_url":"https://github.com/trsouz","followers_url":"https://api.github.com/users/trsouz/followers","following_url":"https://api.github.com/users/trsouz/following{/other_user}","gists_url":"https://api.github.com/users/trsouz/gists{/gist_id}","starred_url":"https://api.github.com/users/trsouz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trsouz/subscriptions","organizations_url":"https://api.github.com/users/trsouz/orgs","repos_url":"https://api.github.com/users/trsouz/repos","events_url":"https://api.github.com/users/trsouz/events{/privacy}","received_events_url":"https://api.github.com/users/trsouz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-08-19T20:10:32Z","updated_at":"2015-10-01T20:24:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scttnlsn/monq/pulls/52","html_url":"https://github.com/scttnlsn/monq/pull/52","diff_url":"https://github.com/scttnlsn/monq/pull/52.diff","patch_url":"https://github.com/scttnlsn/monq/pull/52.patch"},"body":"Hello ... First thank you for Developing the \"monq\"!\r\n\r\nNow I will try to explain the problem that caused me to develop this \"pull-request\".\r\n\r\nI have a task in the \"worker\" which is very simple and runs very fast, but I have to climb the worker to have many processors simultaneously.\r\n\r\nWhen climb these \"worker\" and they try to get tasks at the same time, some can not get any job because \"findAndModify\" returns only the first one asked. The result is that even if 30 \"workers\" ready to work only one of them is working and they alternate each other, but only one at a time works.\r\n\r\nSee example:\r\n\r\n``` javascript\r\n'use strict';\r\n\r\nvar monq = require('monq');\r\n\r\nvar client = monq('mongodb://admin@mongo:27017/myqueue/?', {\r\n  server: {\r\n    auto_reconnect: true,\r\n    // define poolSize 10 to simulate the concurrency\r\n    poolSize: 10\r\n  }\r\n});\r\n\r\nclient.db.collection('jobs', function (err, collection) {\r\n  if (err) {\r\n    console.error(err);\r\n  } else {\r\n    // Loop 10 times to simulate the concurrency\r\n    for (var i = 0; i < 10; i++) {\r\n      collection.findAndModify({\r\n        status: 'queued',\r\n        queue: 'mysqueue',\r\n        delay: {$lte: new Date()}\r\n      }, [['priority', 'desc'], ['_id', 'asc']], {\r\n        $set: {\r\n          status: 'dequeued',\r\n          dequeued: new Date()\r\n        }\r\n      }, {new: true}, function (err, doc, other) {\r\n        if (err) {\r\n          console.err(err);\r\n        } else if(doc){\r\n          console.log(doc);\r\n        }else{\r\n          console.log(other);\r\n        }\r\n      });\r\n    }\r\n  }\r\n});\r\n```\r\n\r\nIf you withdraw the order ([['priority', 'desc'], ['_id', 'asc']]) of \"query\", the mongo then proceeds to answer to everyone.\r\nSo this \"pull-request\" makes it possible to specify the sort of way you prefer.\r\n\r\n(Sorry, my english is not good!)"},"comment":{"url":"https://api.github.com/repos/scttnlsn/monq/issues/comments/144837685","html_url":"https://github.com/scttnlsn/monq/pull/52#issuecomment-144837685","issue_url":"https://api.github.com/repos/scttnlsn/monq/issues/52","id":144837685,"user":{"login":"scttnlsn","id":578446,"avatar_url":"https://avatars.githubusercontent.com/u/578446?v=3","gravatar_id":"","url":"https://api.github.com/users/scttnlsn","html_url":"https://github.com/scttnlsn","followers_url":"https://api.github.com/users/scttnlsn/followers","following_url":"https://api.github.com/users/scttnlsn/following{/other_user}","gists_url":"https://api.github.com/users/scttnlsn/gists{/gist_id}","starred_url":"https://api.github.com/users/scttnlsn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scttnlsn/subscriptions","organizations_url":"https://api.github.com/users/scttnlsn/orgs","repos_url":"https://api.github.com/users/scttnlsn/repos","events_url":"https://api.github.com/users/scttnlsn/events{/privacy}","received_events_url":"https://api.github.com/users/scttnlsn/received_events","type":"User","site_admin":false},"created_at":"2015-10-01T20:24:27Z","updated_at":"2015-10-01T20:24:27Z","body":"So is there any way to maintain the priority functionality here?"}}