Uladz Kha
Uladz Kha

Reputation: 2364

How to import form Json file to MongoDb

How to import a json file to mongodb? I tried:

mongoimport --db test --collection restaurants --drop --file primer-dataset.json

enter image description here

Upvotes: 1

Views: 452

Answers (2)

Alex
Alex

Reputation: 21766

mongoimport is a stand-alone application that needs to be executed from the shell, (Window Command Prompt, Bash, etc). It seems you are currently executing the code inside the Mongo shell itself.

Upvotes: 3

Alex Blex
Alex Blex

Reputation: 37048

The docs read:

The mongoimport tool imports content from an Extended JSON, CSV, or TSV export created by mongoexport, or potentially, another third-party export tool.

The word "potentially" means it should be a valid json with expected structure. Not an arbitrary json.

Upvotes: 1

Related Questions