Export one object with mongoexport, how to specify _id?

前端 未结 5 461
萌比男神i
萌比男神i 2020-12-18 08:23

I\'m trying to export just one object with mongoexport, filtering by its ID.

I tried:

mongoexport -d \"kb_development\" -c \"articles\" -q \"{\'_id\'         


        
5条回答
  •  萌比男神i
    2020-12-18 08:50

    many of the answers provided here didn't work for me, the error was with my double quotes. Here is what worked for me:

    mongoexport -h localhost -d database_name -c collection_name -q {_id:ObjectId('50584580ff0f089602066633')} -o output_file.json
    

    remember to use single quote only for the ObjectId string.

提交回复
热议问题