我在Mongodb上的数据文档如下-
{
"_id" : ObjectId("5c6a2c118983c210d8ed66b7"),
"team" : 1,
"player" : ObjectId("5c68e63e8983c210d8ed66af"),
"player_type" : "striker",
"player_timestamp" : ISODate("2019-02-18T03:52:49.371Z"),
"__v" : 0
}
var playerSchema = new Schema({
player: {type: Schema.Types.ObjectId, required: true, ref: 'User'},
team: {type: Number, required: true},
player_type: {type: String, required: true},
player_timestamp: {type: Date, required: true, get: function(value) {
return value && moment(value).format('x');
}},
}, {timestamps: true});
我一直在用
mongoose 5.1.3
一段时间后,player_timestamp的日期将以epoch-time格式返回。
我最近升级到
mongoose 5.4.12
注意到时间戳返回为
2019-02-18T03:52:49.392Z
.
我如何确保
猫鼬5.4.12
像以前一样返回纪元时间?
编辑:我不知道为什么仅仅因为它提到了纪元时间和猫鼬就被标记为复制品。它与
other question
因为这个问题是在我升级到新版本的猫鼬之后才出现的。这里讨论的新版本猫鼬(5.4.12)仅在2个月前发布,这个问题已经有6年的历史了。所以在5.1.3和5.4.12之间发生了变化。有什么变化?如何从5.1.3中恢复行为而不重新更改代码?