Export one object with mongoexport, how to specify _id?

前端 未结 5 464
萌比男神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条回答
  •  旧巷少年郎
    2020-12-18 08:50

    My MongoDB verion: 3.2.4. when I use mongoexport tool in mongo shell:


    NOT WORK:

    -q '{"_id":ObjectId("5719cd12b1168b9d45136295")}'

    -q '{_id: {"$oid": "5719cd12b1168b9d45136295"}}'


    WORKs:

    -q "{_id:ObjectId('5719cd12b1168b9d45136295')}"


    - Though in mongo doc , it says that

    You must enclose the query in single quotes (e.g. ') to ensure that it does not interact with your shell environment.


    - But, single quote(') does not work! please use double quote(")!

提交回复
热议问题