在我的mongoose模式中,我定义了一些数据类型和两个对象数组。第一个对象dish应该没问题。
但在第二个嵌套的对象order中,我想将第一个对象dish包含到其中,但我不知道正确的方法。
但在第二个嵌套的对象order中,我想将第一个对象dish包含到其中,但我不知道正确的方法。
module.exports = function( mongoose) {
var ShopSchema = new mongoose.Schema({
shopName: { type: String, unique: true },
address: { type: String},
location:{type:[Number],index: '2d'},
shopPicUrl: {type: String},
shopPicTrueUrl:{type: String},
mark: { type: String},
open:{type:Boolean},
shopType:{type:String},
dish: {type: [{
dishName: { type: String},
tags: { type: Array},
price: { type: Number},
intro: { type: String},
dishPic:{ type: String},
index:{type:Number},
comment:{type:[{
date:{type: Date,default: Date.now},
userId:{type: String},
content:{type: String}
}]}
}]},
order:{type:[{
orderId:{type: String},
date:{type: Date,default: Date.now},
dish:{type: [dish]},//!!!!!!!!! could I do this?
userId:{type: String}
}]}
});