【发布时间】:2013-09-21 21:57:22
【问题描述】:
我正在尝试编写一个猫鼬模式,该模式对于所有对 find() 或 findOne() 的调用都将在其字段之一中传递特定值。我尝试在字段声明中使用“默认”属性,但这对我不起作用。
这是我的架构:
var schema = Schema({
created_at: Date,
type: {type: String, default: "alert"},
timestamp: Number,
order: Number,
description: String,
status: String,
});
我希望对 find() 和 findOne() 的每次调用都在“type”字段中传递值“alert”。
有什么想法吗?
【问题讨论】: