【问题标题】:i need assistance : this while updating user information我需要帮助:这是在更新用户信息时
【发布时间】:2022-11-19 20:40:23
【问题描述】:

enter image description here 请在我尝试更新用户的姓氏和名字时出现此错误 有什么帮助吗? (我正在使用 Linux)

请在我尝试更新用户的姓氏和名字时出现此错误 有什么帮助吗? (我正在使用 Linux) 请打开上面的图片看清楚

db.contactList.update({ "_id" : ObjectId("6378c0336c5f81777d8bd4a5")} {$set:{"Last_name":"Kefi"}, {"First_name":"Anis"}})); 未捕获的异常:SyntaxError: missing ) 在参数列表之后: @(贝壳):1:70 db.contactList.update({ "_id" : ObjectId("6378c0336c5f81777d8bd4a5")} {$set:{Last_name:"Kefi"}, {First_name:"Anis"}}); 未捕获的异常:SyntaxError: missing ) 在参数列表之后: @(贝壳):1:70

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    尝试这个:

    db.contacts.updateOne(
      {
        _id: ObjectId('6377ce54ffd3270e15035da7') // id of document you want to update
      }, 
      {
         $set: {
           "Last_name": "Kefi", 
           "First_name": "Anis"
        }
      }
    );
    

    确保您的架构中具有完全相同的属性。

    如果你想使用 update 方法,那么试试这个:

    db.contacts.update(
      {
        _id: ObjectId('6377ce54ffd3270e15035da7') // id of document you want to update
      }, 
      {
         $set: {
           "Last_name": "Kefi", 
           "First_name": "Anis"
        }
      }
    );
    

    【讨论】:

    • 谢谢你它的工作:)
    • 请将答案标记为已接受。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2012-09-18
    • 1970-01-01
    • 2016-11-30
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    相关资源
    最近更新 更多