{"action":"created","issue":{"url":"https://api.github.com/repos/coralproject/pillar/issues/14","labels_url":"https://api.github.com/repos/coralproject/pillar/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/coralproject/pillar/issues/14/comments","events_url":"https://api.github.com/repos/coralproject/pillar/issues/14/events","html_url":"https://github.com/coralproject/pillar/issues/14","id":125455195,"number":14,"title":"Make Source field consistent in all Collections - Simplify Referential Integrity in Import","user":{"login":"samshub","id":14077487,"avatar_url":"https://avatars.githubusercontent.com/u/14077487?v=3","gravatar_id":"","url":"https://api.github.com/users/samshub","html_url":"https://github.com/samshub","followers_url":"https://api.github.com/users/samshub/followers","following_url":"https://api.github.com/users/samshub/following{/other_user}","gists_url":"https://api.github.com/users/samshub/gists{/gist_id}","starred_url":"https://api.github.com/users/samshub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samshub/subscriptions","organizations_url":"https://api.github.com/users/samshub/orgs","repos_url":"https://api.github.com/users/samshub/repos","events_url":"https://api.github.com/users/samshub/events{/privacy}","received_events_url":"https://api.github.com/users/samshub/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-07T18:19:21Z","updated_at":"2016-01-11T17:39:53Z","closed_at":"2016-01-11T17:39:53Z","body":"Since we're creating bson.ObjectId for all ID fields in our collections, we established a standard approach to identify/lookup using original source fields as strings. This was done to find the references and keep integrity in the system.\r\n\r\nFor example the ```Source``` field in a ```Comment``` looks as follows:\r\n~~~\r\n// CommentSource encapsulates all original id from the source system\r\ntype CommentSource struct {\r\n\tID       string `json:\"id\" bson:\"id\" validate:\"required\"`\r\n\tAssetID  string `json:\"asset_id\" bson:\"asset_id\" validate:\"required\"`\r\n\tUserID   string `json:\"user_id\" bson:\"user_id\" validate:\"required\"`\r\n\tParentID string `json:\"parent_id\" bson:\"parent_id\"`\r\n}\r\n~~~ \r\n\r\nThese fields are used to lookup respective items in their own collection and fix the references in a comment.\r\n\r\nHowever, this is not done consistently in other collections. We should make a conscious effort to keep this consistent for all collections such as ```Asset```, ```User``` and ```Action``` as well.\r\n"},"comment":{"url":"https://api.github.com/repos/coralproject/pillar/issues/comments/170628968","html_url":"https://github.com/coralproject/pillar/issues/14#issuecomment-170628968","issue_url":"https://api.github.com/repos/coralproject/pillar/issues/14","id":170628968,"user":{"login":"samshub","id":14077487,"avatar_url":"https://avatars.githubusercontent.com/u/14077487?v=3","gravatar_id":"","url":"https://api.github.com/users/samshub","html_url":"https://github.com/samshub","followers_url":"https://api.github.com/users/samshub/followers","following_url":"https://api.github.com/users/samshub/following{/other_user}","gists_url":"https://api.github.com/users/samshub/gists{/gist_id}","starred_url":"https://api.github.com/users/samshub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samshub/subscriptions","organizations_url":"https://api.github.com/users/samshub/orgs","repos_url":"https://api.github.com/users/samshub/repos","events_url":"https://api.github.com/users/samshub/events{/privacy}","received_events_url":"https://api.github.com/users/samshub/received_events","type":"User","site_admin":false},"created_at":"2016-01-11T17:39:53Z","updated_at":"2016-01-11T17:39:53Z","body":"A common source structure is created and reused across all entities. Here is how this looks:\r\n\r\n~~~\r\ntype source struct {\r\n\tID       string `json:\"id,omitempty\" bson:\"id,omitempty\"`\r\n\tUserID   string `json:\"user_id,omitempty\" bson:\"user_id,omitempty\"`\r\n\tTargetID string `json:\"target_id,omitempty\" bson:\"target_id,omitempty\"`\r\n\tAssetID  string `json:\"asset_id,omitempty\" bson:\"asset_id,omitempty\"`\r\n\tParentID string `json:\"parent_id,omitempty\" bson:\"parent_id,omitempty\"`\r\n}\r\n~~~\r\n"}}