{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/sails/issues/124","labels_url":"https://api.github.com/repos/balderdashy/sails/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/sails/issues/124/comments","events_url":"https://api.github.com/repos/balderdashy/sails/issues/124/events","html_url":"https://github.com/balderdashy/sails/issues/124","id":11091089,"number":124,"title":"Associations","user":{"login":"mikermcneil","id":618009,"avatar_url":"https://avatars.githubusercontent.com/u/618009?v=3","gravatar_id":"","url":"https://api.github.com/users/mikermcneil","html_url":"https://github.com/mikermcneil","followers_url":"https://api.github.com/users/mikermcneil/followers","following_url":"https://api.github.com/users/mikermcneil/following{/other_user}","gists_url":"https://api.github.com/users/mikermcneil/gists{/gist_id}","starred_url":"https://api.github.com/users/mikermcneil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikermcneil/subscriptions","organizations_url":"https://api.github.com/users/mikermcneil/orgs","repos_url":"https://api.github.com/users/mikermcneil/repos","events_url":"https://api.github.com/users/mikermcneil/events{/privacy}","received_events_url":"https://api.github.com/users/mikermcneil/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/balderdashy/sails/milestones/3","labels_url":"https://api.github.com/repos/balderdashy/sails/milestones/3/labels","id":345430,"number":3,"title":"Roadmap","description":"","creator":{"login":"mikermcneil","id":618009,"avatar_url":"https://avatars.githubusercontent.com/u/618009?v=3","gravatar_id":"","url":"https://api.github.com/users/mikermcneil","html_url":"https://github.com/mikermcneil","followers_url":"https://api.github.com/users/mikermcneil/followers","following_url":"https://api.github.com/users/mikermcneil/following{/other_user}","gists_url":"https://api.github.com/users/mikermcneil/gists{/gist_id}","starred_url":"https://api.github.com/users/mikermcneil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikermcneil/subscriptions","organizations_url":"https://api.github.com/users/mikermcneil/orgs","repos_url":"https://api.github.com/users/mikermcneil/repos","events_url":"https://api.github.com/users/mikermcneil/events{/privacy}","received_events_url":"https://api.github.com/users/mikermcneil/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":28,"state":"closed","created_at":"2013-05-31T07:26:30Z","updated_at":"2014-03-02T03:52:39Z","due_on":null,"closed_at":"2014-03-02T03:52:39Z"},"comments":251,"created_at":"2013-02-17T18:12:28Z","updated_at":"2015-02-23T13:57:03Z","closed_at":"2014-03-02T03:45:00Z","body":"## Update:\r\n\r\nSails v0.10.0-rc3 is now available on npm.\r\n\r\n> ##### Upgrading to Sails v0.10 beta:\r\n>\r\n> Install:\r\n> `$ sudo npm install -g sails@beta -g`\r\n>\r\n> Docs:\r\n> [beta.sailsjs.org](http://beta.sailsjs.org/#!documentation/reference/ModelAssociations/ModelAssociations.html)\r\n>\r\n> Also see: https://github.com/balderdashy/waterline-docs\r\n> \r\n> Migration Guide for v0.9.x apps:\r\n> https://github.com/balderdashy/sails-docs/blob/master/Migration-Guide.md\r\n>\r\n\r\n\r\nWe're working on improving docs in general, but we could really use your help- please feel free to submit pull requests to https://github.com/balderdashy/sails-docs.  The changes go live to beta.sailsjs.org (and eventually sailsjs.org proper, when we set the `latest` tag on v0.10)\r\n\r\n--\r\n\r\n\r\n<!--\r\n--------------------------------------------------------------------------------------------------\r\n\r\n--------------------------------------------------------------------------------------------------\r\n\r\n--------------------------------------------------------------------------------------------------\r\n**Original post:**\r\n\r\n# The plan\r\nBy default, standard relational semantics will be used.  \r\n\r\n# hasOne, belongsToOne\r\n\r\n## Relational\r\n\r\n### What goes in your model\r\n```\r\n// User\r\nattributes: {\r\n  name: 'STRING',\r\n  Group: {\r\n    model: 'group'\r\n  }\r\n}\r\n```\r\n\r\n### What's actually stored in the db\r\n```\r\n// User\r\n{\r\n  id: 7,\r\n  name: 'Mike',\r\n  GroupId: 381\r\n}\r\n\r\n// Group\r\n{\r\n  id: 381,\r\n  name: 'Developers'\r\n}\r\n```\r\n\r\n## Non-relational\r\n\r\n### What goes in your model\r\n```\r\n// User\r\nattributes: {\r\n  name: 'STRING',\r\n  Group: {\r\n    name: 'STRING'\r\n  }\r\n}\r\n```\r\n\r\n### what's actually stored in the db\r\n```\r\n// User\r\n{\r\n  id: 7,\r\n  name: 'Mike',\r\n  Group: {\r\n    id: 381,\r\n    name: 'Developers'\r\n  }\r\n}\r\n```\r\n\r\n-->\r\n"},"comment":{"url":"https://api.github.com/repos/balderdashy/sails/issues/comments/75544350","html_url":"https://github.com/balderdashy/sails/issues/124#issuecomment-75544350","issue_url":"https://api.github.com/repos/balderdashy/sails/issues/124","id":75544350,"user":{"login":"xolubi","id":3480376,"avatar_url":"https://avatars.githubusercontent.com/u/3480376?v=3","gravatar_id":"","url":"https://api.github.com/users/xolubi","html_url":"https://github.com/xolubi","followers_url":"https://api.github.com/users/xolubi/followers","following_url":"https://api.github.com/users/xolubi/following{/other_user}","gists_url":"https://api.github.com/users/xolubi/gists{/gist_id}","starred_url":"https://api.github.com/users/xolubi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xolubi/subscriptions","organizations_url":"https://api.github.com/users/xolubi/orgs","repos_url":"https://api.github.com/users/xolubi/repos","events_url":"https://api.github.com/users/xolubi/events{/privacy}","received_events_url":"https://api.github.com/users/xolubi/received_events","type":"User","site_admin":false},"created_at":"2015-02-23T13:57:02Z","updated_at":"2015-02-23T13:57:02Z","body":"@rizr First, change your User model to this\r\n```attributes: {\r\n    name: {\r\n        type: 'string',\r\n        defaultsTo: ''\r\n    },\r\n    roles: {\r\n        model: 'Roles'\r\n}```\r\n\r\nand run your query using this\r\n`User.find().populate('roles', {type: 'admin'})`"}}