How to get mongo command results in to a flat file

后端 未结 8 2072
攒了一身酷
攒了一身酷 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:22

    Try this - returns a json file with the data of the query, you can change .json for .txt and other.

    mongoexport --db products --collection clicks --query '{"createdInt":{$gte:20190101}, "clientId":"123", "country":"ES"}' --out clicks-2019.json
    

提交回复
热议问题