下面是我的架构设计
const Schema1 = mongoose.Schema({
_id: false,
id: { type: mongoose.Schema.Types.ObjectId,
ref: 'UserinfoSchema'
},
name: { type: String , default: null },
from: { type: Date, default: Date.now }
})
const ProfileSchema = mongoose.Schema({
profilename:{
type: String,
required: true
},
list:{
acceptedList:[ Schema1 ],
requestedList:[ Schema1 ],
pendingList:[ Schema1 ]
}
})
我想构建一个查询,它查询所有嵌套数组(即acceptedList、requestList、pendingList)并找出id是否存在,如果id不存在于任何列表中,则更新requestList。
任何技术都是有帮助的。性能是关键。