Created
February 17, 2015 21:45
-
-
Save elxris/bb6ff48392ae132225c4 to your computer and use it in GitHub Desktop.
Mongoose
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 mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var UserSchema = new Schema({ | |
username: {type: String, trim: true}, | |
data: { | |
color: {type: Number} | |
} | |
}); | |
UserSchema.virtual('invertedColor').get(function(){ | |
return parseInt('0xffffff', 16) - this.data.color; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment