在mongoose中如果某一个字段的类型未知,或者希望将来给他赋值一个对象(任何对象),这个该怎么定义,如下
var optLogSchema = new Schema({
target: {//操作对象(任意对象,没有固定的结构)
type:?????
}
});
module.exports = optLogSchema;
回复 (5)
R
var optLogSchema = new Schema({
target: {}
});
K
var optLogSchema = new Schema({
target: {type: Object}
});
这样可以么 感觉好像行啊
3
S
引用 39092207@kenticny 没见过这么写的啊
@39092207 可以的,正式环境用过
M
createPreson : String,
created : {type : Date, default : Date.now},
可以啊。
参与回复
登录后即可参与回复。登录