{"action":"closed","issue":{"url":"https://api.github.com/repos/Webschool-io/be-mean-instagram-nodejs-exercises/issues/196","repository_url":"https://api.github.com/repos/Webschool-io/be-mean-instagram-nodejs-exercises","labels_url":"https://api.github.com/repos/Webschool-io/be-mean-instagram-nodejs-exercises/issues/196/labels{/name}","comments_url":"https://api.github.com/repos/Webschool-io/be-mean-instagram-nodejs-exercises/issues/196/comments","events_url":"https://api.github.com/repos/Webschool-io/be-mean-instagram-nodejs-exercises/issues/196/events","html_url":"https://github.com/Webschool-io/be-mean-instagram-nodejs-exercises/issues/196","id":154921800,"number":196,"title":"TypeError: 'this'","user":{"login":"oescarabel","id":5413228,"avatar_url":"https://avatars.githubusercontent.com/u/5413228?v=3","gravatar_id":"","url":"https://api.github.com/users/oescarabel","html_url":"https://github.com/oescarabel","followers_url":"https://api.github.com/users/oescarabel/followers","following_url":"https://api.github.com/users/oescarabel/following{/other_user}","gists_url":"https://api.github.com/users/oescarabel/gists{/gist_id}","starred_url":"https://api.github.com/users/oescarabel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oescarabel/subscriptions","organizations_url":"https://api.github.com/users/oescarabel/orgs","repos_url":"https://api.github.com/users/oescarabel/repos","events_url":"https://api.github.com/users/oescarabel/events{/privacy}","received_events_url":"https://api.github.com/users/oescarabel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-15T18:13:50Z","updated_at":"2016-05-17T01:38:37Z","closed_at":"2016-05-17T01:38:37Z","body":"### Código\r\n>OBS: Todas as aulas de nodejs que haviam 'this' apresentaram o mesmo erro(ex: aula de *virtuals*), estou com a versão v6.1.0 do node.\r\n\r\n```js\r\n'use strict';\r\nconst mongoose = require('mongoose');\r\nmongoose.connect('mongodb://localhost/teste');\r\n\r\nvar PokemonSchema = new mongoose.Schema({\r\n  name: String\r\n  , description: String\r\n  , type: String\r\n  , attack: Number\r\n  , defense: Number\r\n  , height: Number\r\n});\r\n\r\nPokemonSchema.methods.findSimilarType = (cb) => {\r\n  return this.model('Pokemon').find({type: this.type}, cb);\r\n};\r\n\r\nconst PokemonModel = mongoose.model('Pokemon', PokemonSchema);\r\nconst poke = new PokemonModel({name: 'Insetoide', type: 'inseto'});\r\n\r\npoke.findSimilarType((err, data) => {\r\n  if(err) return console.log('ERRO: '+err);\r\n  return data.foreach((pokemon) => console.log('Pokemon: '+pokemon));\r\n});\r\n```\r\n\r\n### ERRO\r\n```\r\nreturn this.model('Pokemon').find({type: this.type}, cb);\r\n              ^\r\nTypeError: this.model is not a function\r\n    at model.PokemonSchema.methods.findSimilarType (/Users/oescarabel/Documents/programming/developments/workshop-be-mean/nodejs/mongoose-atomic/schema-method.js:15:15)\r\n    at Object.<anonymous> (/Users/oescarabel/Documents/programming/developments/workshop-be-mean/nodejs/mongoose-atomic/schema-method.js:21:6)\r\n    at Module._compile (module.js:541:32)\r\n    at Object.Module._extensions..js (module.js:550:10)\r\n    at Module.load (module.js:456:32)\r\n    at tryModuleLoad (module.js:415:12)\r\n    at Function.Module._load (module.js:407:3)\r\n    at Function.Module.runMain (module.js:575:10)\r\n    at startup (node.js:160:18)\r\n    at node.js:445:3\r\n\r\n```"}}