Explain this custom mongoose schema method

var animalSchema = new Schema({ name: String, type: String });

animalSchema.methods.findSimilarTypes = function(cb) {
return this.model("Animal").find({ type: this.type }, cb);
};

var Animal = mongoose.model("Animal", animalSchema);
var dog = new Animal({ type: "dog" });

dog.findSimilarTypes(function(err, dogs) {
console.log(dogs); // woof
});

here you define a schema and then assign a method to findSimilarTypes. Why is it specified here as this.model ("Animal") instead of the Animal model defined later? What is the this here?

Feb.27,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2b67f-2ba8c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2b67f-2ba8c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?