{"action":"created","issue":{"url":"https://api.github.com/repos/aheinze/cockpit/issues/343","labels_url":"https://api.github.com/repos/aheinze/cockpit/issues/343/labels{/name}","comments_url":"https://api.github.com/repos/aheinze/cockpit/issues/343/comments","events_url":"https://api.github.com/repos/aheinze/cockpit/issues/343/events","html_url":"https://github.com/aheinze/cockpit/issues/343","id":96047632,"number":343,"title":"Get the prev/next posts in JS","user":{"login":"manudurgoni","id":2260385,"avatar_url":"https://avatars.githubusercontent.com/u/2260385?v=3","gravatar_id":"","url":"https://api.github.com/users/manudurgoni","html_url":"https://github.com/manudurgoni","followers_url":"https://api.github.com/users/manudurgoni/followers","following_url":"https://api.github.com/users/manudurgoni/following{/other_user}","gists_url":"https://api.github.com/users/manudurgoni/gists{/gist_id}","starred_url":"https://api.github.com/users/manudurgoni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manudurgoni/subscriptions","organizations_url":"https://api.github.com/users/manudurgoni/orgs","repos_url":"https://api.github.com/users/manudurgoni/repos","events_url":"https://api.github.com/users/manudurgoni/events{/privacy}","received_events_url":"https://api.github.com/users/manudurgoni/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-20T11:50:55Z","updated_at":"2015-07-28T11:40:04Z","closed_at":null,"body":"Hey,\r\n\r\nI really appreciate Cockpit !\r\n\r\nBut I've a problem to get the prev/next posts from a current entry.\r\n\r\nI'd like to have the posts just before and after my entry with _id `_this.actualite._id`\r\n\r\nI've found in the mongoDB docs the `$lt`and `$gt` but how I can use those properties ?\r\n\r\nI've tried this, but it doesn't work :\r\n\r\n```js\r\nCockpit.request('/cockpit/call', {\r\n    module: 'collections',\r\n    method: 'find',\r\n    args: [\r\n       'Actualites', {\r\n          filter: {\r\n             'categorie': _this.categorie._id,\r\n              _id: {\r\n                 $lt: _this.actualite._id\r\n              }\r\n           },\r\n           limit: 1,\r\n           sort: {\r\n             _id: -1\r\n           }\r\n        }]\r\n        }).success(function(item) {\r\n          console.log(item);\r\n          console.log(item[0].titre);\r\n      });\r\n```\r\n\r\nMaybe someone can help me :)\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/aheinze/cockpit/issues/comments/125568744","html_url":"https://github.com/aheinze/cockpit/issues/343#issuecomment-125568744","issue_url":"https://api.github.com/repos/aheinze/cockpit/issues/343","id":125568744,"user":{"login":"piotr-cz","id":612953,"avatar_url":"https://avatars.githubusercontent.com/u/612953?v=3","gravatar_id":"","url":"https://api.github.com/users/piotr-cz","html_url":"https://github.com/piotr-cz","followers_url":"https://api.github.com/users/piotr-cz/followers","following_url":"https://api.github.com/users/piotr-cz/following{/other_user}","gists_url":"https://api.github.com/users/piotr-cz/gists{/gist_id}","starred_url":"https://api.github.com/users/piotr-cz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piotr-cz/subscriptions","organizations_url":"https://api.github.com/users/piotr-cz/orgs","repos_url":"https://api.github.com/users/piotr-cz/repos","events_url":"https://api.github.com/users/piotr-cz/events{/privacy}","received_events_url":"https://api.github.com/users/piotr-cz/received_events","type":"User","site_admin":false},"created_at":"2015-07-28T11:40:04Z","updated_at":"2015-07-28T11:40:04Z","body":"Why won't you load whole collection (respecting the order), lookup current entry and pick previous/ next entries from an array?\r\nThat's how it's done for example in [Joomla CMS](https://github.com/joomla/joomla-cms/blob/3.4.3/plugins/content/pagenavigation/pagenavigation.php#L172). You could also add a _collection-link_ type field and set up these manually.\r\n\r\nThe `$lt` and `$gt` are comparators when picking up entries based on criteria, I think it's better to use them in conjunction with an custom-order field.\r\nBTW: I have bad experience with filtering the `_id` field, Cockpit handles this propety in a different way."}}