Created
April 19, 2012 19:27
-
-
Save dopa/2423456 to your computer and use it in GitHub Desktop.
How to use Moment.js with Mongoose's Virtuals
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 moment = require('moment') | |
, dateMask = 'YYYY-MM-DD'; | |
var MeetingSchema = new Schema({ | |
... | |
}); | |
MeetingSchema | |
.virtual('startDate_yyyymmdd') | |
.get(function () { | |
return moment(this.startDate).format(dateMask); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment