您可以在架构上将数字毫秒版本添加
timestamp为虚拟属性:
schema.virtual('timestamp_ms').get(function() { return this.timestamp.getTime();});然后,可以
toObject通过模式上的选项启用虚拟字段包含在模型实例的调用中:
var schema = new Schema({ timestamp: Date}, { toObject: { getters: true }});
您可以在架构上将数字毫秒版本添加
timestamp为虚拟属性:
schema.virtual('timestamp_ms').get(function() { return this.timestamp.getTime();});然后,可以
toObject通过模式上的选项启用虚拟字段包含在模型实例的调用中:
var schema = new Schema({ timestamp: Date}, { toObject: { getters: true }});