{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1688","repository_url":"https://api.github.com/repos/strongloop/loopback","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1688/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1688/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1688/events","html_url":"https://github.com/strongloop/loopback/issues/1688","id":107327540,"number":1688,"title":"model with embedsOne relation is not saved on db [sandbox attached]","user":{"login":"kranthitech","id":3313458,"avatar_url":"https://avatars.githubusercontent.com/u/3313458?v=3","gravatar_id":"","url":"https://api.github.com/users/kranthitech","html_url":"https://github.com/kranthitech","followers_url":"https://api.github.com/users/kranthitech/followers","following_url":"https://api.github.com/users/kranthitech/following{/other_user}","gists_url":"https://api.github.com/users/kranthitech/gists{/gist_id}","starred_url":"https://api.github.com/users/kranthitech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kranthitech/subscriptions","organizations_url":"https://api.github.com/users/kranthitech/orgs","repos_url":"https://api.github.com/users/kranthitech/repos","events_url":"https://api.github.com/users/kranthitech/events{/privacy}","received_events_url":"https://api.github.com/users/kranthitech/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback/labels/triage","name":"triage","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2015-09-19T11:46:35Z","updated_at":"2016-09-27T18:57:48Z","closed_at":null,"body":"I have created an example of an Author having a pen name using embedsOne relationship. Here is the attached sandbox for this example - https://github.com/kranthitech/loopback-sandbox\r\n\r\nWhen I create a new Author with a pen name, the corresponding pen name object gets attached to the author along with a generated id. But when I try to list out all the created pen names using find, I get an empty array.\r\n\r\nExpected behaviour:\r\nShould list the newly created pen name\r\n\r\nActual Behaviour:\r\nShowing list of pen names as empty\r\n\r\nSandbox:\r\nhttps://github.com/kranthitech/loopback-sandbox"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/249963158","html_url":"https://github.com/strongloop/loopback/issues/1688#issuecomment-249963158","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/1688","id":249963158,"user":{"login":"loay","id":1986928,"avatar_url":"https://avatars.githubusercontent.com/u/1986928?v=3","gravatar_id":"","url":"https://api.github.com/users/loay","html_url":"https://github.com/loay","followers_url":"https://api.github.com/users/loay/followers","following_url":"https://api.github.com/users/loay/following{/other_user}","gists_url":"https://api.github.com/users/loay/gists{/gist_id}","starred_url":"https://api.github.com/users/loay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loay/subscriptions","organizations_url":"https://api.github.com/users/loay/orgs","repos_url":"https://api.github.com/users/loay/repos","events_url":"https://api.github.com/users/loay/events{/privacy}","received_events_url":"https://api.github.com/users/loay/received_events","type":"User","site_admin":false},"created_at":"2016-09-27T18:57:48Z","updated_at":"2016-09-27T18:57:48Z","body":"Hi @kranthitech \r\nI checked your sandbox. You still need to create both the parent and child separately.\r\nQuoting from the documents:\r\n`\r\nTreat embedsMany as an actual relation, no different from hasMany, for example. This means that you cannot just POST the full object with embedded/nested data to create everything all at once. So using the example above to add a Customer and multiple email addresses would require two POST operations, one for the Customer record and one for the multiple email address data.\r\n`\r\nIn your case it is embedsOne, which is the same behavior. \r\n\r\nMore reference: \r\n\r\nhttps://docs.strongloop.com/display/public/LB/Embedded+models+and+relations#Embeddedmodelsandrelations-EmbedsMany\r\n\r\nLet me know if you need any further assistance. Thanks\r\n "}}
{"actor":{"display_login":"loay"}}