{"action":"created","issue":{"url":"https://api.github.com/repos/NodeBB/NodeBB/issues/4161","repository_url":"https://api.github.com/repos/NodeBB/NodeBB","labels_url":"https://api.github.com/repos/NodeBB/NodeBB/issues/4161/labels{/name}","comments_url":"https://api.github.com/repos/NodeBB/NodeBB/issues/4161/comments","events_url":"https://api.github.com/repos/NodeBB/NodeBB/issues/4161/events","html_url":"https://github.com/NodeBB/NodeBB/pull/4161","id":131801069,"number":4161,"title":"mongo.getObjects potential optimization","user":{"login":"akhoury","id":1398375,"avatar_url":"https://avatars.githubusercontent.com/u/1398375?v=3","gravatar_id":"","url":"https://api.github.com/users/akhoury","html_url":"https://github.com/akhoury","followers_url":"https://api.github.com/users/akhoury/followers","following_url":"https://api.github.com/users/akhoury/following{/other_user}","gists_url":"https://api.github.com/users/akhoury/gists{/gist_id}","starred_url":"https://api.github.com/users/akhoury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akhoury/subscriptions","organizations_url":"https://api.github.com/users/akhoury/orgs","repos_url":"https://api.github.com/users/akhoury/repos","events_url":"https://api.github.com/users/akhoury/events{/privacy}","received_events_url":"https://api.github.com/users/akhoury/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-06T01:02:35Z","updated_at":"2016-02-06T04:21:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NodeBB/NodeBB/pulls/4161","html_url":"https://github.com/NodeBB/NodeBB/pull/4161","diff_url":"https://github.com/NodeBB/NodeBB/pull/4161.diff","patch_url":"https://github.com/NodeBB/NodeBB/pull/4161.patch"},"body":"`mongo.getObjects` calls toArray, then converts to Map, then back to Array, all this to clean the `_key` field.\r\n\r\n@barisusakli can you this of a condition where this wouldn't work. `getObject` does that already"},"comment":{"url":"https://api.github.com/repos/NodeBB/NodeBB/issues/comments/180678470","html_url":"https://github.com/NodeBB/NodeBB/pull/4161#issuecomment-180678470","issue_url":"https://api.github.com/repos/NodeBB/NodeBB/issues/4161","id":180678470,"user":{"login":"akhoury","id":1398375,"avatar_url":"https://avatars.githubusercontent.com/u/1398375?v=3","gravatar_id":"","url":"https://api.github.com/users/akhoury","html_url":"https://github.com/akhoury","followers_url":"https://api.github.com/users/akhoury/followers","following_url":"https://api.github.com/users/akhoury/following{/other_user}","gists_url":"https://api.github.com/users/akhoury/gists{/gist_id}","starred_url":"https://api.github.com/users/akhoury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akhoury/subscriptions","organizations_url":"https://api.github.com/users/akhoury/orgs","repos_url":"https://api.github.com/users/akhoury/repos","events_url":"https://api.github.com/users/akhoury/events{/privacy}","received_events_url":"https://api.github.com/users/akhoury/received_events","type":"User","site_admin":false},"created_at":"2016-02-06T04:21:36Z","updated_at":"2016-02-06T04:21:36Z","body":"ok i see the difference now.. if an object isn't there, you won't have an `undefined` entry in the returned array, along with the order being not being conserved - but you you care? if you think of it as a SQL DB call right? you never get the items that doesn't exists, and you surely don't get them sorted unless you explicitly specify how to `order by`\r\n\r\n```javascript\r\n\tdescribe('getObjects()', function() {\r\n\t\tbefore(function(done) {\r\n\t\t\tasync.parallel([\r\n\t\t\t\tasync.apply(db.setObject, 'key1', {name: \"k1\"}),\r\n\t\t\t\tasync.apply(db.setObject, 'key2', {name: \"k2\"}),\r\n\t\t\t\tasync.apply(db.setObject, 'key3', {name: \"k3\"})\r\n\t\t\t], done);\r\n\t\t});\r\n\r\n\t\tit('should return 4 objects with correct data', function(done) {\r\n\t\t\tdb.getObjects(['key1', 'key3', 'doesnotexist', 'key2'], function(err, results) {\r\n\t\t\t\tconsole.log('\\n', typeof results); // object.. weird but ok.\r\n\t\t\t\tconsole.log(Array.isArray(results)); // true\r\n\t\t\t\tconsole.log(results.length); // 3, not the expected 4\r\n\t\t\t\t// also the order is not as the same as the keys requested\r\n\t\t\t\tconsole.log(results); // {name: k1}, {name: k2}, {name: k3} // even though the keys order was key1, key3, key2\r\n\t\t\t});\r\n\t\t});\r\n\t});\r\n\r\n```\r\n    \r\n"}}