db.col.insertMany(
[
{
"_id" : "tt0084726",
"title" : "Star Trek II: The Wrath of Khan",
"year" : 1982,
"type" : "movie"
},
{
"_id" : "tt0796366",
"title" : "Star Trek",
"year" : 2009,
"type" : "movie"
},
{
"_id" : "tt0084726",
"title" : "Star Trek II: The Wrath of Khan",
"year" : 1982,
"type" : "movie"
}
]
);
OS:LinuxMint 17.3 Rosa MongoDB:db version v2.6.12
我正在参加University of MongoDB的课程。当我将上述命令输入mongo shell时,会出现错误:TypeError: Property 'insertMany' of object test.col is not a function
怎么解决?我已经阅读了文档,但仍然失败了。
答案 0 :(得分:6)
答案 1 :(得分:1)
我是MongoDB
的新手,在另一种情况下我遇到了类似的错误。我在此补充一个答案,任何未来的读者可能会发现有用!
db.users.insertMany (
[ {name:"Ajith",status:"pending",age:25}, {name:"Kumar",status:"withheld",age:40}, {name:"Lal",status:"passed",age:34}, {name:"Tishil Joppen",status:"high",age:28}
] )
我忘了用方括号括起来,并且得到了同样的错误!