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

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.2.3
    • Component/s: None
    • Labels:
      None

      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.

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

              Created:
              Updated:
              Resolved: