Skip to content

Instantly share code, notes, and snippets.

@rashfael
Created January 16, 2012 23:21
Show Gist options
  • Save rashfael/1623550 to your computer and use it in GitHub Desktop.
Save rashfael/1623550 to your computer and use it in GitHub Desktop.
mongoose: Getter gets called with undefined parameter
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