TypeError:mongodb属性insertmany不是函数

时间:2016-06-02 07:38:23

标签: 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"
        }
    ]
);
  

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 怎么解决?我已经阅读了文档,但仍然失败了。

2 个答案:

答案 0 :(得分:6)

我有类似的问题。您需要版本3.2

> New in version 3.2.

您需要更新您的mongodb版本以使用jquery

不是那么难。几周前我用它来insertMany

答案 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} ] )

我忘了用方括号括起来,并且得到了同样的错误!