How to get mongo command results in to a flat file

后端 未结 8 2306
攒了一身酷
攒了一身酷 2021-01-30 06:26

How do I export the results of a MongoDB command to a flat file

For example, If I am to get db.collectionname.find() into a flat file.

I tried

8条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-30 07:17

    mongoexport --host 127.0.0.1 --port 27017 --username youruser -p yourpass \
       -d yourDatabaseName -c collectionName --type csv \
       --fields field1,field2 -q '{"field1" : 1495730914381}' \
       --out report.csv
    

提交回复
热议问题