我正在尝试使用mongoDB shell将对象数组添加到我的数据库中。我收到"SyntaxError: Unexpected String"
错误。
代码:
db.Tests.insert(
{
"id": "chapter1"
"questions": [
{
"questionID": "1",
"question": "How much is 1+1",
"Answer1": "1",
"Answer2": "2",
"Answer3": "3",
"Answer4": "4",
"CorrectAns": "2"
}
]
}
)
答案 0 :(得分:0)
db.Tests.insert(
{
"id": "chapter1", // <=== here is the bug
"questions": [
{
"questionID": "1",
"question": "How much is 1+1",
"Answer1": "1",
"Answer2": "2",
"Answer3": "3",
"Answer4": "4",
"CorrectAns": "2"
}
]
}
)