Created
March 6, 2012 02:15
-
-
Save shiawuen/1982919 to your computer and use it in GitHub Desktop.
Can instance methods not be called from within other instance methods?
This file contains 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 goose = require('mongoose') | |
, db = goose.connect('mongodb://localhost/testmongo') | |
, Schema = goose.Schema | |
, sc = new Schema({ | |
a: String, | |
b: Date | |
}) | |
sc.methods.bbb = function() { | |
return this.b.getFullYear() | |
} | |
sc.methods.aaa = function() { | |
return this.a + this.bbb() | |
} | |
var M = db.model('sc', sc) | |
, m = new M({a: 'test', b: new Date()}) | |
// Can instance methods not be called from within other instance methods? | |
// WORKS! | |
console.log(m.aaa()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool. thx.