0
假设我想要一个数据模式:每个用户可以有多个笔记本电脑,并且有些笔记本电脑可用。 我希望我可以得到一些架构一样,将数组保存在Mongoose模式中
User
| userId: 1
| laptops:
| laptopId: 1 available: true //default
| laptopId: 2 available: true
我如何定义这种模式? 以下是不正确的:
const User = new mongoose.Schema({
userId: {
type: String,
index: { unique: true }
},
laptops: {
laptopId: String,
available: Boolean
}
});
如何在node.js中的猫鼬定义呢?