【问题标题】:MongoShell: SyntaxError: missing : after property id @(shell):1:137 mongoMongo Shell: SyntaxError: missing : after property id @(shell):1:137 mongo
【发布时间】:2017-06-26 13:09:51
【问题描述】:

试图从mac终端插入mongoshell:

    db.recipe.insert({ "_Title": "newname", "_Ingredients": 
    "newingredients" , "_Instructions": "newinstructions" ," 
    _Time":1,"_Category": "newcategory", "_Author": "newauthor" , 
    "_RecipeVersion": 1})

报错:

SyntaxError: missing : after property id @(shell):1:137

不确定我在这里缺少什么......

【问题讨论】:

  • 我无法复制您的错误。我得到WriteResult({ "nInserted" : 1 })。

标签: mongodb shell terminal syntax-error database


【解决方案1】:

您的 JSON 对象中似乎存在不寻常的间距 - 我刚刚在我的代码编辑器中对其进行了格式化,清理了间距并且它起作用了:

db.recipe.insert({ 
  "_Title": "newname", 
  "_Ingredients": "newingredients" , 
  "_Instructions": "newinstructions" ,
  "_Time":1,
  "_Category": "newcategory", 
  "_Author": "newauthor", 
  "_RecipeVersion": 1
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-12
    • 1970-01-01
    • 1970-01-01
    • 2018-07-28
    相关资源
    最近更新 更多