noob
noob

Reputation: 148

Can't Import a Json Array to Mongodb

I'm trying to import a jsonArray to a mongoDB with windows command prompt.

My command is,

C:\mongo>mongoimport --jsonArray -d testdb -c testcollection -f my_test_file.json

The file my_test_file.json does exist at C:\mongo and the file contains following,

[{"id": 1, "data":"test"}]

The output of the command prompt is only connected to: 127.0.0.1 and no import happens.

The command promt that runs the db says connection accepted when I ran the command above.

Can anyone notice what I'm missing here?

Upvotes: 2

Views: 5108

Answers (1)

Piotr Kostecki
Piotr Kostecki

Reputation: 96

The flag "-f" indicates fields but not file as I assume you thought. Just remove it from your command and everything should work just fine.

C:\mongo>mongoimport --jsonArray -d testdb -c testcollection my_test_file.json

Upvotes: 8

Related Questions