{"action":"created","issue":{"url":"https://api.github.com/repos/maximegris/typescript-express-sequelize/issues/1","repository_url":"https://api.github.com/repos/maximegris/typescript-express-sequelize","labels_url":"https://api.github.com/repos/maximegris/typescript-express-sequelize/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/maximegris/typescript-express-sequelize/issues/1/comments","events_url":"https://api.github.com/repos/maximegris/typescript-express-sequelize/issues/1/events","html_url":"https://github.com/maximegris/typescript-express-sequelize/issues/1","id":246252200,"node_id":"MDU6SXNzdWUyNDYyNTIyMDA=","number":1,"title":"How to define instance methods in models files.?","user":{"login":"vidur149","id":13303065,"node_id":"MDQ6VXNlcjEzMzAzMDY1","avatar_url":"https://avatars3.githubusercontent.com/u/13303065?v=4","gravatar_id":"","url":"https://api.github.com/users/vidur149","html_url":"https://github.com/vidur149","followers_url":"https://api.github.com/users/vidur149/followers","following_url":"https://api.github.com/users/vidur149/following{/other_user}","gists_url":"https://api.github.com/users/vidur149/gists{/gist_id}","starred_url":"https://api.github.com/users/vidur149/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vidur149/subscriptions","organizations_url":"https://api.github.com/users/vidur149/orgs","repos_url":"https://api.github.com/users/vidur149/repos","events_url":"https://api.github.com/users/vidur149/events{/privacy}","received_events_url":"https://api.github.com/users/vidur149/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-28T06:16:39Z","updated_at":"2018-08-03T16:35:04Z","closed_at":null,"author_association":"NONE","body":"Hey, \r\nI was going through your example of sequelize models. I am unable to understand how to write instance methods that require querying other models.\r\nI have a doubt while writing the instance methods on a model. Let us assume there is a `user model` and a user has the option to create todos. Now a user can have many todos. How to write a function in the user models that returns the number of todos a user has. Example\r\n```typescript\r\ninstanceMethods: {\r\n      countTodos: function() {\r\n          // returns total number of todos of a user.\r\n      }\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/maximegris/typescript-express-sequelize/issues/comments/410308228","html_url":"https://github.com/maximegris/typescript-express-sequelize/issues/1#issuecomment-410308228","issue_url":"https://api.github.com/repos/maximegris/typescript-express-sequelize/issues/1","id":410308228,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDMwODIyOA==","user":{"login":"rimiti","id":28003749,"node_id":"MDQ6VXNlcjI4MDAzNzQ5","avatar_url":"https://avatars0.githubusercontent.com/u/28003749?v=4","gravatar_id":"","url":"https://api.github.com/users/rimiti","html_url":"https://github.com/rimiti","followers_url":"https://api.github.com/users/rimiti/followers","following_url":"https://api.github.com/users/rimiti/following{/other_user}","gists_url":"https://api.github.com/users/rimiti/gists{/gist_id}","starred_url":"https://api.github.com/users/rimiti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rimiti/subscriptions","organizations_url":"https://api.github.com/users/rimiti/orgs","repos_url":"https://api.github.com/users/rimiti/repos","events_url":"https://api.github.com/users/rimiti/events{/privacy}","received_events_url":"https://api.github.com/users/rimiti/received_events","type":"User","site_admin":false},"created_at":"2018-08-03T16:35:04Z","updated_at":"2018-08-03T16:35:04Z","author_association":"NONE","body":"@vidur149 +1"}}
{"actor":{"display_login":"rimiti"}}