Mongo Import and Export
records = [];
var cursor = db.getCollection('foo').find({}, {});
while(cursor.hasNext()) {
    records.push(cursor.next())
}
print(tojson(records));mongoimport --db bala --collection book1 --type json --file C:\Users\balaji\Desktop\test1.json --jsonArray
mongo is the command-line shell that connects to a specific instance of mongodmongo import query will not work inside the shell
When I try to import my json data file into my local instance of mongodb, I get an error. The code that I am using is shown below.
> mongoimport --db cities --collection zips --type json --file C:/MongoDB/data/zips.jsonThis is the error that I get.
2014-11-29T20:27:33.803-0800 SyntaxError: Unexpected identifier
what seems to be to problem here?
I just found out that 
mongoimport is used from terminal/command line(cmd), and NOT within the mongo shell. 
 
Comments
Post a Comment