Javascript 缺失),我的代码有什么问题;(
当我试着在我的shell上运行这个时,我得到了一个错误,上面写着这样的内容Javascript 缺失),我的代码有什么问题;(,javascript,json,mongodb,Javascript,Json,Mongodb,当我试着在我的shell上运行这个时,我得到了一个错误,上面写着这样的内容 db.products.updateOne( { name: "Pen" } { $set: { reviews: [ { username: "John", rating: "4.5", comment: "Hell buy this thing"
db.products.updateOne(
{
name: "Pen"
}
{
$set: {
reviews:
[
{
username: "John",
rating: "4.5",
comment: "Hell buy this thing"
},
{
username: "John",
rating: "4.5",
comment: "Hell buy this thing"
}
]
}
})
我找不到解决这个问题的办法,很抱歉问了N00b问题……;)
而且我也找不到我在哪里做了一个类型或类似missing(),{},[],对我来说很好,但没有工作请帮助第一行代码和错误不同:
db.products.updateOne(
和db.products.updateOne({
。它是哪一个?在查询{name:“Pen}后缺少逗号,
),
但我只是复制了最上面的一个并粘贴到我的shell中。是的,我在“笔”后添加了一个逗号,但仍然没有在@turivishal中输入任何语法错误。因此,更正后没有语法错误,您可能遗漏了一些内容。
> db.products.updateOne({
... {
... name: "Pen"
... }
... {
... $set: {
... reviews: [{
... username: "John",
... rating: "4.5",
... comment: "Hell buy this thing"
... },
... {
... username: "John",
... rating: "4.5",
... comment: "Hell buy this thing"
... }
... ]
... }
... }})
uncaught exception: SyntaxError: expected property name, got '{' :
@(shell):2:2
> db.products.updateOne(
... {
... name: "Pen"
... }
... {
... $set: {
... reviews: [{
... username: "John",
... rating: "4.5",
... comment: "Hell buy this thing"
... },
... {
... username: "John",
... rating: "4.5",
... comment: "Hell buy this thing"
... }
... ]
... }
... })
uncaught exception: SyntaxError: missing ) after argument list :
@(shell):5:1