Getting an approval error in the mongoexport command in Mongodb.

I get an error after running this command:

mongoexport --db records --collection source_list --csv --out C:\bcopy.csv 

record is my DB n source_list is my collection

Displays this message:

 assertion: 9998 you need to specify fields 

I also tried to specify the fields, but it gives me the same error.

What changes should I make in the team to get a backup of my collection, or is there any other way to do this?

+4
source share
3 answers

Here is an example of a command indicating the exported fields:

 mongoexport -h 127.0.0.1 --port 27018 --db mydb --collection system.profile --csv --out profile.csv --fields ns,millis,numYield,nscanned 
+2
source

--Headerline helped in my case. I had about 60 columns; listing them with -f would be rather cumbersome.

- headerline If you use "--type csv" or "--type tsv", use the first line as the field names. Otherwise> mongoimport imports the first line as a separate document.

+2
source

It looks like you should use -f paramater to select the fields that will be exported to the csv file. For this case, an error is reported to change the explanation because the error message is not informative enough.

https://jira.mongodb.org/browse/SERVER-4224

+1
source

All Articles