Created
January 16, 2012 23:21
-
-
Save rashfael/1623550 to your computer and use it in GitHub Desktop.
mongoose: Getter gets called with undefined parameter
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
mongoose = require 'mongoose' | |
TestSchema = new mongoose.Schema { | |
number: | |
type: Number | |
set: (x) -> return x/2 | |
get: (x) -> | |
console.log 'getter called with undefined' if not x? | |
x*2 if x? | |
} | |
Test = mongoose.model 'test', TestSchema | |
test = new Test {number: 42.42} | |
console.log test.number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment