//1对多
const childSchema = new Schema({
msg: []
});
const parentSchema = new Schema({
id: 'string',
children: [childSchema]
})
const c = await model.Parent.findOneAndUpdate({
id: 'id1'
}, {
$push: { //更新子数据
children: datas
}
}, {
upsert: true, // 查不到,则添加新数据
})