Skip to content

Instantly share code, notes, and snippets.

@dopa
Created April 19, 2012 19:27
Show Gist options
  • Save dopa/2423456 to your computer and use it in GitHub Desktop.
Save dopa/2423456 to your computer and use it in GitHub Desktop.
How to use Moment.js with Mongoose's Virtuals
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