您可以尝试将日期戳嵌套在父对象中,然后验证父对象。例如:
//create a simple object defining your datesvar dateStampSchema = { startDate: {type:Date}, endDate: {type:Date}};//validation functionfunction checkDates(value) { return value.endDate < value.startDate; }//now pass in the dateStampSchema object as the type for a schema fieldvar schema = new Schema({ dateInfo: {type:dateStampSchema, validate:checkDates}});


