mongodb findByIdAndUpdate查询并得到了SyntaxError:Unexpected token ILLEGAL

问题描述 投票:1回答:1
db.getCollection('comments').findByIdAndUpdate({"taskId": mongoose.Types.ObjectId(5b7fb3fe79c0831ec027a5bd)},{ '$push': { "commentDetail": { comment: 'sfsf fsdf' } }})

这是我的查询。获得了意外的令牌ILLEGAL。我刚刚开始学习Mongo和Node。

node.js mongodb
1个回答
1
投票

使用findOneAndUpdate。喜欢

db.getCollection('comments').findOneAndUpdate({"taskId": mongoose.Types.ObjectId(5b7fb3fe79c0831ec027a5bd)},{ '$push': { "commentDetail": { comment: 'sfsf fsdf' } }})
© www.soinside.com 2019 - 2024. All rights reserved.