Cannot import companies.json

i have sandbox cluster,how to import companies.json.so that i can practice Lecture:facets:single facet query

The best resource is the documentation at https://docs.mongodb.com/manual/reference/program/mongoimport/.

vagrant@m103:~$ mongoimport “mongodb+srv://sandbox-cocqu.mongodb.net:2017/test” --db startup --collection companies --type json --file companies.json --username m001-student --password m001-mongodb-basics --authenticationDatabase admin
2020-01-28T17:46:58.694+0000 error validating settings: incompatible options: --file and positional argument(s)

is this correct command to import companies.json

You do not use –file as specified in the documentation.

vagrant@m103:/dataset$ mongoimport --host sandbox-shard-00-01-cocqu.mongodb.net:27017 --db startup --type json --file companies.json --jsonArray --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics
2020-01-28T18:42:43.542+0000 no collection specified
2020-01-28T18:42:43.543+0000 using filename ‘companies’ as collection
2020-01-28T18:42:43.847+0000 connected to: sandbox-shard-00-01-cocqu.mongodb.net:27017
2020-01-28T18:42:43.870+0000 Failed: error reading separator after document #1: bad JSON array format - found no opening bracket ‘[’ in input source
2020-01-28T18:42:43.871+0000 imported 0 documents
iam getting above error

i removed the field --jsonArray,it worked.

iam able to import companies.json

1 Like