{"action":"closed","issue":{"url":"https://api.github.com/repos/vuex-orm/vuex-orm/issues/80","repository_url":"https://api.github.com/repos/vuex-orm/vuex-orm","labels_url":"https://api.github.com/repos/vuex-orm/vuex-orm/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/vuex-orm/vuex-orm/issues/80/comments","events_url":"https://api.github.com/repos/vuex-orm/vuex-orm/issues/80/events","html_url":"https://github.com/vuex-orm/vuex-orm/issues/80","id":297244075,"number":80,"title":"Unable to see child models within object state","user":{"login":"clockworked247","id":1016149,"avatar_url":"https://avatars0.githubusercontent.com/u/1016149?v=4","gravatar_id":"","url":"https://api.github.com/users/clockworked247","html_url":"https://github.com/clockworked247","followers_url":"https://api.github.com/users/clockworked247/followers","following_url":"https://api.github.com/users/clockworked247/following{/other_user}","gists_url":"https://api.github.com/users/clockworked247/gists{/gist_id}","starred_url":"https://api.github.com/users/clockworked247/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clockworked247/subscriptions","organizations_url":"https://api.github.com/users/clockworked247/orgs","repos_url":"https://api.github.com/users/clockworked247/repos","events_url":"https://api.github.com/users/clockworked247/events{/privacy}","received_events_url":"https://api.github.com/users/clockworked247/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-02-14T21:02:31Z","updated_at":"2018-02-15T01:50:36Z","closed_at":"2018-02-15T01:50:36Z","author_association":"NONE","body":"Hi there, thanks for the great plugin for Vuex.  I'm still struggling to get it working, unfortunately.\r\n\r\nApologies in advance, I've been going through the docs and trying out the example calls to Vuex ORM: https://vuex-orm.gitbooks.io/vuex-orm/store/retrieving-data.html\r\n\r\nI must be doing something wrong...\r\n\r\nGiven the following Models:\r\n\r\n**App Model**\r\n\r\n```\r\nimport { Model } from '@vuex-orm/core'\r\nimport Workspace from './Workspace'\r\n\r\nexport default class App extends Model {\r\n  static entity = 'apps'\r\n\r\n  static fields () {\r\n    return {\r\n        workspaces: this.hasMany(Workspace, 'appId'),\r\n        workspaceLoaded: this.attr(false)\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n**Workspace Model**\r\n\r\n```\r\nimport { Model } from '@vuex-orm/core'\r\nimport Query from './Query'\r\nimport App from './App'\r\n\r\nexport default class Workspace extends Model {\r\n  static entity = 'workspaces'\r\n\r\n  static fields () {\r\n    return {\r\n        id: this.attr(null),\r\n        appId: this.attr(null),\r\n        app: this.belongsTo(App, 'appId'),\r\n        name: this.attr('Workspace'),\r\n        active: this.attr(true),\r\n        queries: this.hasMany(Query, 'workspaceId')\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nI create an app with two workspace objects:\r\n\r\n```\r\nmyVue.$store.dispatch('entities/apps/create',{\r\n        data: {\r\n            'workspaces': [\r\n                {\r\n                    id: 111,\r\n                    name: 'Workspace 1',\r\n                    active: true,\r\n                    queries: [\r\n                        ... array of JSON query objects ...\r\n                    ]\r\n                },\r\n                {\r\n                    id: 222,\r\n                    name: 'Workspace 2',\r\n                    active: false,\r\n                    queries: [\r\n                        ... array of JSON query objects ...\r\n                    ]\r\n                }\r\n            ]\r\n        }\r\n    })\r\n```\r\n\r\nOnce this is complete, I use the getters to get the instance of the only App object state:\r\n`myVue.$store.getters['entities/apps/all']()[0]`\r\n\r\nWhen looking at the workspaces property (Array), it has no items (usually IDs).\r\n\r\nBut, if I look directly at the state, I see related child object IDs:\r\n`myVue.$store.state.entities.apps.data._no_key_0.workspaces`\r\nI see an array of my two workspace IDs.  \r\n\r\nSo, why can't I see these child IDs by using the getter call?\r\n\r\nThanks in advance!"}}
{"actor":{"display_login":"clockworked247"}}