{"action":"created","issue":{"url":"https://api.github.com/repos/mdehoog/ember-data-has-many-query/issues/17","repository_url":"https://api.github.com/repos/mdehoog/ember-data-has-many-query","labels_url":"https://api.github.com/repos/mdehoog/ember-data-has-many-query/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/mdehoog/ember-data-has-many-query/issues/17/comments","events_url":"https://api.github.com/repos/mdehoog/ember-data-has-many-query/issues/17/events","html_url":"https://github.com/mdehoog/ember-data-has-many-query/issues/17","id":188746002,"number":17,"title":"Sticky belongs-to doesn't work","user":{"login":"danilovaz","id":1218337,"avatar_url":"https://avatars.githubusercontent.com/u/1218337?v=3","gravatar_id":"","url":"https://api.github.com/users/danilovaz","html_url":"https://github.com/danilovaz","followers_url":"https://api.github.com/users/danilovaz/followers","following_url":"https://api.github.com/users/danilovaz/following{/other_user}","gists_url":"https://api.github.com/users/danilovaz/gists{/gist_id}","starred_url":"https://api.github.com/users/danilovaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danilovaz/subscriptions","organizations_url":"https://api.github.com/users/danilovaz/orgs","repos_url":"https://api.github.com/users/danilovaz/repos","events_url":"https://api.github.com/users/danilovaz/events{/privacy}","received_events_url":"https://api.github.com/users/danilovaz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-11T12:03:50Z","updated_at":"2016-11-18T17:00:34Z","closed_at":"2016-11-18T17:00:34Z","body":"Thank's for this amazing addon. \r\n\r\nI'm using:\r\n```\r\nEmber             : 2.9.0\r\nEmber Data        : 2.9.0\r\njQuery            : 3.1.1\r\nEmber Simple Auth : 1.1.0\r\n```\r\n\r\nI'm have problems with `Sticky belongs-to`. My project has model `chat` and model `chatMessage`. `chat` `hasMany` `chaMessages` and `chatMessages` `belongsTo` `chat`.\r\n\r\n**model chat.js**\r\n```js\r\nimport Model from 'ember-data/model';\r\nimport attr from 'ember-data/attr';\r\nimport { belongsTo, hasMany } from 'ember-data/relationships';\r\nimport HasManyQuery from 'ember-data-has-many-query';\r\n\r\nexport default Model.extend(HasManyQuery.ModelMixin,{\r\n  name: attr('string'),\r\n  date: attr('date'),\r\n  chatMessages: hasMany('chat-message', { async: true })\r\n});\r\n```\r\n\r\n**model chatMessage.js**\r\n```js\r\nimport Model from 'ember-data/model';\r\nimport attr from 'ember-data/attr';\r\n//import emojione from 'emojione';\r\nimport { belongsTo, hasMany } from 'ember-data/relationships';\r\nimport HasManyQuery from 'ember-data-has-many-query';\r\n\r\nexport default Model.extend(HasManyQuery.ModelMixin,{\r\n  message: attr('string'),\r\n  date: attr('date'),\r\n  chat: HasManyQuery.belongsToSticky('chat')\r\n});\r\n```\r\nI'm implementing an action like \"Read More\" to get more items from `chatMessages`. My API expect a request with params:\r\n`https://myapi.com/chats/2/chat-messages?page%5Bnumber%5D=1475591389&page%limit%5D=20`\r\n\r\n**Route** `chats/show`: `https://myapi.com/chats/2/chat-messages`\r\n```js\r\nmodel(params) {\r\n    return Ember.RSVP.hash({\r\n      chat: this.store.findRecord('chat', params.chat_id)\r\n    })\r\n}\r\n```\r\nIn this pieace of code above, I'm get the `chat` user has selected: `https://myapi.com/chats/2/chat-messages` and because I'm using `JSONAPI` this already push `chatMessages` in store.\r\n\r\nSo when user click in action \"readMore\" I'm doing this:\r\n```js\r\nactions: {\r\n    readMore(chatId, pageNumber) {\r\n      this._super(...arguments);\r\n      let chat = this.controller.get('model.chat');\r\n\r\n      this.set('chat-messages', Ember.ObjectProxy.extend(Ember.PromiseProxyMixin).create({\r\n        promise: this.controller.get('model.chat').query('chatMessages', { page: { number: pageNumber } })\r\n      }));\r\n   }\r\n}\r\n```\r\nWith this, I'm capable to get items from `https://myapi.com/chats/2/chat-messages?page%5Bnumber%5D=1475591389&page%limit%5D=20` BUT :sob: it's clear the frist 20 items I'm already get in: `https://myapi.com/chats/2/chat-messages`\r\n\r\nHow can I persist this data? I'm following `Sticky belongs-to` but it's doesn't work. Please, you can help with this? Have any idea?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/mdehoog/ember-data-has-many-query/issues/comments/261583725","html_url":"https://github.com/mdehoog/ember-data-has-many-query/issues/17#issuecomment-261583725","issue_url":"https://api.github.com/repos/mdehoog/ember-data-has-many-query/issues/17","id":261583725,"user":{"login":"danilovaz","id":1218337,"avatar_url":"https://avatars.githubusercontent.com/u/1218337?v=3","gravatar_id":"","url":"https://api.github.com/users/danilovaz","html_url":"https://github.com/danilovaz","followers_url":"https://api.github.com/users/danilovaz/followers","following_url":"https://api.github.com/users/danilovaz/following{/other_user}","gists_url":"https://api.github.com/users/danilovaz/gists{/gist_id}","starred_url":"https://api.github.com/users/danilovaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danilovaz/subscriptions","organizations_url":"https://api.github.com/users/danilovaz/orgs","repos_url":"https://api.github.com/users/danilovaz/repos","events_url":"https://api.github.com/users/danilovaz/events{/privacy}","received_events_url":"https://api.github.com/users/danilovaz/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T17:00:34Z","updated_at":"2016-11-18T17:00:34Z","body":"Thank's @mdehoog I'll follow your tip."}}
{"actor":{"display_login":"danilovaz"}}