{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/750","repository_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler","labels_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/750/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/750/comments","events_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/750/events","html_url":"https://github.com/strongloop/loopback-datasource-juggler/issues/750","id":114831931,"number":750,"title":"EmbedsMany ID's with MongoDB set to String instead of ObjectID","user":{"login":"sebastianhaas","id":6751545,"avatar_url":"https://avatars.githubusercontent.com/u/6751545?v=3","gravatar_id":"","url":"https://api.github.com/users/sebastianhaas","html_url":"https://github.com/sebastianhaas","followers_url":"https://api.github.com/users/sebastianhaas/followers","following_url":"https://api.github.com/users/sebastianhaas/following{/other_user}","gists_url":"https://api.github.com/users/sebastianhaas/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastianhaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastianhaas/subscriptions","organizations_url":"https://api.github.com/users/sebastianhaas/orgs","repos_url":"https://api.github.com/users/sebastianhaas/repos","events_url":"https://api.github.com/users/sebastianhaas/events{/privacy}","received_events_url":"https://api.github.com/users/sebastianhaas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/connectors-nosql","name":"connectors-nosql","color":"eeeeee"},{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/juggler-relations","name":"juggler-relations","color":"eeeeee"},{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/triage","name":"triage","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2015-11-03T14:44:23Z","updated_at":"2016-08-05T21:05:30Z","closed_at":null,"body":"When posting embedded models to a MongoDB datasource, the embedded instances ID's appear to be of type `String` instead of `ObjectId` like in any other case where we're dealing with IDs.\r\n\r\nPlease take a look at my test case at https://github.com/sebastianhaas/embeds-many-string-id.\r\n\r\nSTR:\r\n* `npm install`\r\n* `node .`\r\n\r\nThis will create an instance of the model `Book` and an embedded instance of `Chapter` in that book. The actual JSON in the database will be something like\r\n```\r\n{\r\n    \"_id\" : ObjectId(\"5638c3466baf4c1e60accdd0\"),\r\n    \"title\" : \"A first book\",\r\n    \"chapterList\" : [ \r\n        {\r\n            \"title\" : \"Chapter One\",\r\n            \"pages\" : 65,\r\n            \"id\" : \"9650ecce677750439cea5df1\" <--- String\r\n        }\r\n    ]\r\n}\r\n```\r\nwhere the chapter's ID is not an `ObjectId` but a `String`.\r\n\r\nPlease note that while this is a minimal example I already tried different options on the relation and a few other suggestions from the forums, SO and github issues.\r\nThese, amongst others, include:\r\n* Any possible combination of `persistent: true`, `forceId: true`, `validate: true` as relation options\r\n* Manually specifying a ID property of type `String` or `ObjectId` with any possible combination of \r\n`    \"id\": {\r\n      \"type\": \"string\",\r\n      \"required\": true,\r\n      \"generated\": true,\r\n      \"id\": true,\r\n      \"defaultFn\": \"uuid\"\r\n    },`"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/comments/237965999","html_url":"https://github.com/strongloop/loopback-datasource-juggler/issues/750#issuecomment-237965999","issue_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/750","id":237965999,"user":{"login":"jannyHou","id":12554153,"avatar_url":"https://avatars.githubusercontent.com/u/12554153?v=3","gravatar_id":"","url":"https://api.github.com/users/jannyHou","html_url":"https://github.com/jannyHou","followers_url":"https://api.github.com/users/jannyHou/followers","following_url":"https://api.github.com/users/jannyHou/following{/other_user}","gists_url":"https://api.github.com/users/jannyHou/gists{/gist_id}","starred_url":"https://api.github.com/users/jannyHou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jannyHou/subscriptions","organizations_url":"https://api.github.com/users/jannyHou/orgs","repos_url":"https://api.github.com/users/jannyHou/repos","events_url":"https://api.github.com/users/jannyHou/events{/privacy}","received_events_url":"https://api.github.com/users/jannyHou/received_events","type":"User","site_admin":false},"created_at":"2016-08-05T21:05:30Z","updated_at":"2016-08-05T21:05:30Z","body":"@sebastianhaas @Amir-61 Since you attach `Chapter` to transient datasource, according to idType definition in transient connector: \r\nhttps://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/connectors/transient.js#L30\r\n, the default idType is `String`, i think that's why you get a string type.\r\n\r\nBut what confuses me is, you set `idInject` as `false` and don't define an id property for model `Chapter`, then which function defines the id property for you?"}}
{"actor":{"display_login":"jannyHou"}}