files本身是一个数组,想根据files中的id进行更新files中的status属性,并添加一个新对象,名字为reviewUsers,
const newFile = {
userId:userId,
pathologyId:fileId,
groupId:groupId,
userName:userName,
};
MongoClient.connect(mongoURL, function (err, db) {
if (err) throw err;
const dbo = db.db("path-cloud");
dbo.collection('AnnotationFileGroups').update({
_id: groupId,
'files.id': fileId
}, {$addToSet: {'files.$.status': 2,'files.$.reviewUsers':newFile}}, (e, result) => {})
现在是这么写的提示错误Cannot apply $addToSet to non-array field. Field named 'status' has non-array type int