我正在使用在我的ubuntu 18.04机器上运行的mongo shell。我正在将文档插入集合
我尝试创建多个密钥,例如: 'db.Pricing.insert({key1:{key1a:value},key2:{key2a:value},{key2b:value},key3:{key3a:value}})'
'db.Pricing.insert({图像:{“在书中使用”:100},图纸:{“在书中”:0-20},出版社:[{“中”:10999}, {“ Large”:11999}],Flushmount:[{“ Medium / Large”:17999},{“ Wide”:17999}],Magnum:{“ All Sizes:17999}})''
我希望输出将文档插入集合中,但是它的错误是 '2019-07-02T12:23:52.153 + 0530 E查询[thread1]语法错误:缺少:在属性ID @(shell):1:90之后
答案 0 :(得分:0)
以JSONLINT等任何json格式检查您要插入的json
答案 1 :(得分:0)
db.Pricing.insert({
"Images": {
"used in the book": 100
},
"Sheets": {
"in the book": "0-20"
},
"Press book": [{
"Medium": 10999
}, {
"Large": 11999
}],
"Flushmount": [{
"Medium/Large": 17999
}, {
"Wide": 17999
}],
"Magnum": {
"All Sizes": 17999
}
})
您有两个错误,
此外,在第一个插入语句db.Pricing.insert({key1:{key1a:value},key2:{key2a:value}, {key2b:value},key3:{key3a:value}})
{key2b:value}中没有键。它应该类似于Key2:{key2b:value}。值未定义,您必须提供一个值或将其包装在引号中