{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1077","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1077/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1077/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1077/events","html_url":"https://github.com/strongloop/loopback/issues/1077","id":56899361,"number":1077,"title":"How to override 'find'  function in model","user":{"login":"chinuy","id":1298520,"avatar_url":"https://avatars.githubusercontent.com/u/1298520?v=3","gravatar_id":"","url":"https://api.github.com/users/chinuy","html_url":"https://github.com/chinuy","followers_url":"https://api.github.com/users/chinuy/followers","following_url":"https://api.github.com/users/chinuy/following{/other_user}","gists_url":"https://api.github.com/users/chinuy/gists{/gist_id}","starred_url":"https://api.github.com/users/chinuy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinuy/subscriptions","organizations_url":"https://api.github.com/users/chinuy/orgs","repos_url":"https://api.github.com/users/chinuy/repos","events_url":"https://api.github.com/users/chinuy/events{/privacy}","received_events_url":"https://api.github.com/users/chinuy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-07T06:03:56Z","updated_at":"2015-02-07T06:25:09Z","closed_at":null,"body":"I am creating a transparent interface to end point.\r\n\r\nFor example, a _user_ has his/her first name in another model called _profile_. For convenience, I want my _find_ function can default has filter: {include: 'profiles'}\r\n\r\nI consult #443 and have following code\r\n```\r\nUser.on('attached', function() {\r\n    var override = User.find;\r\n    User.find = function(filter, callback) {\r\n        return override(filter, callback);\r\n    }\r\n});\r\n```\r\n\r\nAnd I get this error: TypeError: Object #<Object> has no method 'getDataSource\r\n\r\nIs any clue that I can work on?"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/73352325","html_url":"https://github.com/strongloop/loopback/issues/1077#issuecomment-73352325","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/1077","id":73352325,"user":{"login":"raymondfeng","id":540892,"avatar_url":"https://avatars.githubusercontent.com/u/540892?v=3","gravatar_id":"","url":"https://api.github.com/users/raymondfeng","html_url":"https://github.com/raymondfeng","followers_url":"https://api.github.com/users/raymondfeng/followers","following_url":"https://api.github.com/users/raymondfeng/following{/other_user}","gists_url":"https://api.github.com/users/raymondfeng/gists{/gist_id}","starred_url":"https://api.github.com/users/raymondfeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raymondfeng/subscriptions","organizations_url":"https://api.github.com/users/raymondfeng/orgs","repos_url":"https://api.github.com/users/raymondfeng/repos","events_url":"https://api.github.com/users/raymondfeng/events{/privacy}","received_events_url":"https://api.github.com/users/raymondfeng/received_events","type":"User","site_admin":false},"created_at":"2015-02-07T06:25:09Z","updated_at":"2015-02-07T06:25:09Z","body":"You need to call override with the correct receiver:\r\n```js\r\n    var override = User.find;\r\n    User.find = function(filter, callback) {\r\n        return override.apply(this, arguments);\r\n    }\r\n```"}}