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
I am participating in a course by the University of MongoDB. When I input the command as above into mongo shell, an Error occurs: TypeError: Property 'insertMany' of object test.col is not a function
how to solve it? I have read the docs but still failed.
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
I am participating in a course by the University of MongoDB. When I input the command as above into mongo shell, an Error occurs: TypeError: Property 'insertMany' of object test.col is not a function
how to solve it? I have read the docs but still failed.
- 3 what version of mongo are you using ? – jack blank Commented Jun 2, 2016 at 7:40
- MongoDB shell version: 2.6.12 – muzikmoe Commented Jun 2, 2016 at 7:42
- please use that link you can find the detail : stackoverflow.com/a/68662249/10936485 – Sonu P. Commented Aug 5, 2021 at 7:27
4 Answers
Reset to default 10I had a similar problem. You need to have version 3.2
> New in version 3.2.
You need to update your version of mongodb to use insertMany
.
It's not so hard. I did it a couple weeks ago to use insertMany
I am newbie in MongoDB
, I got similar error in another scenario. I am adding that also an answer here, any future reader may find useful!
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}
])
I forgot to include the square brackets , and got the same error!!
since your Mongo version is MongoDB: db version v2.6.12 (< 3.2) you need to run
db.col.insert(
[
{
"_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"
}
]);
Ensure your table name is plural:
db.cols.insertMany