Created
January 14, 2013 18:46
-
-
Save aheckmann/4532288 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var assert = require('assert') | |
console.log('\n==========='); | |
console.log(' mongoose version: %s', mongoose.version); | |
console.log('========\n\n'); | |
var schema = new Schema({ | |
name: String | |
}); | |
schema.statics.doStuff = function () { | |
console.log('doStuff'); | |
this.doOtherStuff(); | |
} | |
schema.statics.doOtherStuff = function () { | |
console.log('doOtherStuff'); | |
} | |
var A = mongoose.model('A', schema); | |
A.doStuff(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Aaron,
Thanks for that.
I had incorrectly referred to
this.doOtherStuff()
inside an anonymous function indoStuff()
.The this scope was not the right one...
eg.
My understanding is
this.doOtherStuff()
refers to the this scope of the anonymous functionfunction(err,item) {}
instead of the expectedfunction(id,callback) {}