【发布时间】:2025-12-17 22:20:09
【问题描述】:
我正在使用 mongoose 和 mongoose 时间戳插件,但有时我想添加一个具有特定 createdAt 的对象,而不是现在,有什么方法可以覆盖时间戳?
var timestamps = require('goodeggs-mongoose-timestamps');
var Schema = mongoose.Schema;
var ClientSchema = new Schema({
name: {
type: String,
required: true
},
removed: {
type: Boolean,
default: false
},
});
ClientSchema.plugin(timestamps);
module.exports = mongoose.model('Client', ClientSchema);
【问题讨论】:
标签: mongoose