0
我試圖改寫貓鼬模型的制定者,因爲我要創造我自己的Date對象,但檢查documentation,我也跟隨,但二傳手仍是不叫:貓鼬架構二傳手覆蓋功能是不是叫
var mongoose = require('mongoose');
function strToDate(dateStr){
var dateStr = dateStr.split('/');
console.log('parsed a date!');
return new Date(dateStr[0],dateStr[1],dateStr[2],dateStr[3],dateStr[4], dataStr[5]);
}
var infoSchema = new mongoose.Schema({
code: {type : String, require: true},
valve: {type : Number, require: true},
dataTime: {type: Date, require: true, set: strToDate},
status: {type: Boolean, require: true, default: false },
elapsedTime: 0
});
var dataLogSchema = new mongoose.Schema({
boardId: {type: String, require: true, unique: true},
logInfo:[infoSchema]
});
module.exports = mongoose.model('DataLog', dataLogSchema);
有什麼不對?我使用的是貓鼬4.0.5