草庐IT

userIdArray

全部标签

node.js - MongoDB Node Driver updateMany 按 ID 过滤

我在Node.JS中遇到MongoDB驱动程序问题。当尝试通过ID更新多个用户时,MongoDB返回错误:{"name":"MongoError","message":"Argumentmustbeastring"}当省略新ObjectId对象的数组并使用普通的ID字符串时,它不会返回任何错误,但标识符也不会被推送到实例数组。userIdArray=userIdArray.map(id=>newObjectId(id));this.collection.updateMany({_id:{$in:userIdArray}},{$push:{instances:identifier}})当