Skip to content

Instantly share code, notes, and snippets.

@elxris
Created February 17, 2015 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elxris/bb6ff48392ae132225c4 to your computer and use it in GitHub Desktop.
Save elxris/bb6ff48392ae132225c4 to your computer and use it in GitHub Desktop.
Mongoose
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