mongodb - Export data to csv file using $in -


i trying export data csv file using mongo export condition following command

mongoexport --db <db_name> --collection <coll_name> --query "'meta.metadata.fieldname' : {$in : [ezr-2016-21123,ezr-2016-22016, ezr-2016-23420]}}" --fields <field_name> --type=csv --out out_file_name.csv 

this works fine other normal query, when put $in, doesn't work.

you need updated query following

mongoexport --db <db_name> --collection <coll_name> --query "{'meta.metadata.fieldname' : {'$in' : ['ezr-2016-21123', 'ezr-2016-22016', 'ezr-2016-23420']}}" --fields <field_name> --type=csv --out out_file_name.csv 
  • you missing starting { off query
  • strings within $in array need quoted

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -