{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1552","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1552/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1552/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1552/events","html_url":"https://github.com/strongloop/loopback/issues/1552","id":98035548,"number":1552,"title":"embedsMany does not populate auto id","user":{"login":"james-gardner","id":30635,"avatar_url":"https://avatars.githubusercontent.com/u/30635?v=3","gravatar_id":"","url":"https://api.github.com/users/james-gardner","html_url":"https://github.com/james-gardner","followers_url":"https://api.github.com/users/james-gardner/followers","following_url":"https://api.github.com/users/james-gardner/following{/other_user}","gists_url":"https://api.github.com/users/james-gardner/gists{/gist_id}","starred_url":"https://api.github.com/users/james-gardner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/james-gardner/subscriptions","organizations_url":"https://api.github.com/users/james-gardner/orgs","repos_url":"https://api.github.com/users/james-gardner/repos","events_url":"https://api.github.com/users/james-gardner/events{/privacy}","received_events_url":"https://api.github.com/users/james-gardner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-07-29T21:42:48Z","updated_at":"2015-08-06T11:19:47Z","closed_at":null,"body":"There are a couple of issues relating to errors being thrown relating to embedsMany and auto id:\r\n\r\nhttps://github.com/strongloop/loopback/issues/556\r\nhttps://github.com/strongloop/loopback-datasource-juggler/issues/336\r\n\r\nBoth of which are closed. I am however still able to reproduce the index issue and get the following message:\r\n\r\n    {\r\n      \"error\": {\r\n        \"name\": \"ValidationError\",\r\n        \"status\": 422,\r\n        \"message\": \"The `order` instance is not valid. Details: `items` contains invalid item at index `0`: `id` is blank (value: [ { name: 'Sample Product...} ]).\",\r\n        \"statusCode\": 422,\r\n        \"details\": {\r\n          \"context\": \"order\",\r\n          \"codes\": {\r\n            \"items\": [\r\n              \"invalid\"\r\n            ]\r\n          },\r\n          \"messages\": {\r\n            \"items\": [\r\n              \"contains invalid item at index `0`: `id` is blank\"\r\n            ]\r\n          }\r\n        }\r\n      }\r\n    }\r\n\r\nI've defined models for 'customer', 'order' and 'items'.\r\n\r\nCustomer\r\n\r\n    {\r\n        \"name\": \"customer\",\r\n        \"base\": \"PersistedModel\",\r\n        \"idInjection\": true,\r\n        \"properties\": {\r\n            \"firstName\": {\r\n                \"type\": \"string\",\r\n                \"required\": true\r\n            },\r\n            \"lastName\": {\r\n                \"type\": \"string\",\r\n                \"required\": true\r\n            }\r\n        },\r\n        \"validations\": [],\r\n        \"relations\": {\r\n            \"order\": {\r\n                \"type\": \"hasMany\",\r\n                \"model\": \"order\",\r\n                \"foreignKey\": \"\"\r\n            }\r\n        },\r\n        \"acls\": [],\r\n        \"methods\": []\r\n    }\r\n\r\nOrder\r\n\r\n    {\r\n        \"name\": \"order\",\r\n        \"base\": \"PersistedModel\",\r\n        \"idInjection\": true,\r\n        \"properties\": {},\r\n        \"validations\": [],\r\n        \"relations\": {\r\n            \"customer\": {\r\n                \"type\": \"belongsTo\",\r\n                \"model\": \"customer\"\r\n            },\r\n            \"item\": {\r\n                \"type\": \"embedsMany\",\r\n                \"model\": \"item\",\r\n                \"options\": {\r\n                    \"validate\": true,\r\n                    \"forceId\": false\r\n                }\r\n            }\r\n        },\r\n        \"acls\": [],\r\n        \"methods\": []\r\n    }\r\n\r\nItem\r\n\r\n    {\r\n        \"name\": \"item\",\r\n        \"base\": \"PersistedModel\",\r\n        \"idInjection\": true,\r\n        \"properties\": {\r\n            \"name\": {\r\n                \"type\": \"string\",\r\n                \"required\": true\r\n            },\r\n            \"description\": {\r\n                \"type\": \"string\",\r\n                \"required\": true\r\n            },\r\n            \"quantity\": {\r\n                \"type\": \"number\",\r\n                \"required\": true\r\n            },\r\n            \"price\": {\r\n                \"type\": \"number\",\r\n                \"required\": true\r\n            }\r\n        },\r\n        \"validations\": [],\r\n        \"acls\": [],\r\n        \"methods\": []\r\n    }\r\n\r\nI get the error when I try and POST the following data to 'order':\r\n\r\n    {\r\n        \"customerId\": 1,\r\n        \"items\": [\r\n            {   \r\n                \"name\": \"Sample Product A\",\r\n                \"description\": \"An exotic and rare example product crafted with indulgence.\",\r\n                \"quantity\": 1,\r\n                \"price\": 4.99,\r\n                \"orderId\": 1\r\n            }\r\n        ]\r\n    }\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/128331613","html_url":"https://github.com/strongloop/loopback/issues/1552#issuecomment-128331613","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/1552","id":128331613,"user":{"login":"jamesjjk","id":13486303,"avatar_url":"https://avatars.githubusercontent.com/u/13486303?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesjjk","html_url":"https://github.com/jamesjjk","followers_url":"https://api.github.com/users/jamesjjk/followers","following_url":"https://api.github.com/users/jamesjjk/following{/other_user}","gists_url":"https://api.github.com/users/jamesjjk/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesjjk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesjjk/subscriptions","organizations_url":"https://api.github.com/users/jamesjjk/orgs","repos_url":"https://api.github.com/users/jamesjjk/repos","events_url":"https://api.github.com/users/jamesjjk/events{/privacy}","received_events_url":"https://api.github.com/users/jamesjjk/received_events","type":"User","site_admin":false},"created_at":"2015-08-06T11:19:47Z","updated_at":"2015-08-06T11:19:47Z","body":"@fabien I have figured out what I did wrong - I should have been using the embedded models name not the property to reference it a function. This is my mistake, I appologies for the inconvenience. Still an issue remaining with the IDs when 'It probably works because it falls back to normal create which does support arrays. But that's not really intended behavior, it's a coincidence. Although I can see the value of having this functionality.' But as you said that is not the intended behavior. Thanks for all your help!"}}