Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2500

mongoexport doesn't accept the same JSON query input as mongo

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 4.2.3
    • Fix Version/s: No version
    • Component/s: None
    • Labels:
      None

      Description

      I expect if that if mongo can parse a given `find` query, then mongoexport can parse that query too. Turns out that is not the case: mongoexport expects strict JSON input, with double quotes around all keys.

      This works as expected:

      mongo ${MONGO_URL} --quiet --eval "db.tweets.find({ _id: '...' })"

      This fails with "Failed: error parsing query as Extended JSON: invalid JSON input":

      mongoexport --uri=${MONGO_URL} -c tweets -q "{ _id: '...' }"

      This makes it extra cumbersome to use mongoexport in shell scripts due to having to escape all the quotes.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            dan@cryptoclimate.io Dan Dascalescu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: