Quantcast
Channel: Mongoexport error parsing query - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Mongoexport error parsing query

$
0
0

Im trying to do a mongoexport to CSV but only selecting certain records with a query. Here's my command (windows 7 cmd):

mongoexport --host foo.com --port 27017 --username bar -p --db foo --csv --fields col1,col2,col3 --collection bar --out dump_q.csv --query '{"recent":"yes"}'

However after entering the password, I get an error:

assertion: 16619 code FailedToParse: FailedToParse: Expecting '{': offset:0

The command works fine without the query argument but I cant figure out whats wrong with the query:

--query '{"recent":"yes"}'

Any help much appreciated


Summary of answer:

  1. Make sure you use double quotes on enclose the query and single quotes to enclose strings e.g.

    --query "{'recent':'yes'}"

  2. Also make sure you don't have a space in your query otherwise the command prompt will parse it as another argument. So don't have:

    --query "{'recent': 'yes'}"(notice the space in-between)

  3. Queries which include nested fields don't work such as:

    --query "{'folder.recent':'yes'}"


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images