MongoShell:SyntaxError:missing:属性id @(shell):1:137 mongo

时间:2017-06-26 13:09:52

标签: mongodb shell terminal syntax-error database

尝试从mac终端插入mongoshell:

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

给出错误:

  

SyntaxError:missing:属性id @(shell)之后:1:137

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

1 个答案:

答案 0 :(得分:0)

您的JSON对象中似乎有不寻常的间距 - 我只是在我的代码编辑器中对其进行了格式化,清理了间距并且工作正常:

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