muz*_*moe 5 javascript mongodb
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"
}
]
);
Run Code Online (Sandbox Code Playgroud)
操作系统:LinuxMint 17.3 Rosa MongoDB:db版本v2.6.12
我正在参加MongoDB大学的课程.当我将上述命令输入mongo shell时,会出现错误:TypeError: Property 'insertMany' of object test.col is not a function
如何解决?我已经阅读了文档,但仍然失败了.
我是新手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}])
我忘记包含方括号,并得到同样的错误!
我遇到了类似的问题.你需要有3.2版本
您需要更新您要使用的mongodb版本insertMany.
这不是那么难.我几周前就用它做了insertMany