I would like to attach some extra properties to mongoose schema fields and access them later.
Suppose I have a schema which looks like that:
var dauStatsSchema = {
dtKey:{type:Number},
date:{type:Date},
appId: {type: String},
users: {type: Number}
};
Now I'd like to add some metadata to each field, something like this:
var dauStatsSchema = {
dtKey:{type:Number, selector: {$month: '$date'} },
date:{type:Date, selector: {$week: '$date'} },
appId: {type: String, selector: {$dayOfYear: '$date'}},
users: {type: Number}
};
You will notice the selector
properties I added and would like to access those from the model, by doing something like this:
mongoose.model('dauStats').dtKey.selector
, mongoose.model('dauStats').date.selector
, mongoose.model('dauStats').appId.selector
etc.
Any ideas?
Thanks!