{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/397","repository_url":"https://api.github.com/repos/strongloop/loopback","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/397/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/397/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/397/events","html_url":"https://github.com/strongloop/loopback/issues/397","id":38607325,"number":397,"title":"A better way for customizing built-in models and models from components","user":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"labels":[{"id":83708492,"url":"https://api.github.com/repos/strongloop/loopback/labels/feature","name":"feature","color":"c2e0c6","default":false},{"id":484521294,"url":"https://api.github.com/repos/strongloop/loopback/labels/stale","name":"stale","color":"fef2c0","default":false}],"state":"closed","locked":false,"assignee":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"assignees":[{"login":"bajtos","id":1140553,"avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/strongloop/loopback/milestones/10","html_url":"https://github.com/strongloop/loopback/milestone/10","labels_url":"https://api.github.com/repos/strongloop/loopback/milestones/10/labels","id":848707,"number":10,"title":"#Epic: Components","description":null,"creator":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":13,"state":"closed","created_at":"2014-10-31T17:31:55Z","updated_at":"2017-09-06T17:30:26Z","due_on":"2014-11-30T08:00:00Z","closed_at":"2016-09-27T16:15:40Z"},"comments":45,"created_at":"2014-07-24T08:29:04Z","updated_at":"2018-04-27T13:29:32Z","closed_at":"2017-09-06T17:30:26Z","author_association":"OWNER","body":"Consider an application with a \"User\" model that has few extra properties or methods compared to the built-in User model.\n\nAt the moment, the recommended solution is to create a `user` model extending the built-in `User` model, which is rather silly.\n\n**What we would like to have instead**\n\nSupport `redefine:true` as an alternative to `base: \"User\"`. A redefined \"User\" model is defined in `common/models/user.json` and scaffolded by `yo loopback`. This will allow redefinition of common models in the server facet.\n\nIn the long term (loopback 3.x), we were discussing a mixin-based approach, where User would be just a thin wrapper mixing in login/logout and other features provided by the current User implementation.\n\n---\n\n**Original issue description**\n\nPossible solutions:\n1. Implement namespaces, move all built-in models to `loopback` namespace. Application models can live in the global namespace, i.e. `User` extends `loopback.User`.\n2. Implement means allowing applications to modify the built-in models, so that they can use them directly.\n\nSee also https://github.com/strongloop/loopback-datasource-juggler/issues/119\n\nA probably related problem: the canonical project layout has three facets - \"common\", \"server\", \"client\". In many cases it is needed to provide different implementation of model methods on the server. The current approach is to create a new \"server\" model extending the shared \"common\" model and make any changes in this subclass. While this keeps the design clean, it's also rather cumbersome."},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/384970079","html_url":"https://github.com/strongloop/loopback/issues/397#issuecomment-384970079","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/397","id":384970079,"user":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"created_at":"2018-04-27T13:29:32Z","updated_at":"2018-04-27T13:29:32Z","author_association":"OWNER","body":"@RishiMahendru sure. Create your own base model inheriting from PersistedModel, and then use this model as a base for all your application models.\r\n\r\nThis question is pretty off-topic here, please post in on StackOverflow if you need more information."}}
{"actor":{"display_login":"bajtos"}}