Reputation: 4426
mongoexport --db ucc_prod /host:myserver /port:27017 --username user1 --password password1 /query:'{copysheet: {$regex: "/^.*pdf/"}}' /out:copysheets.csv --type=csv --fields svOrderId,svItemId --collection copies
gives me error
2016-09-02T08:17:34.632-0500 error parsing command line options: unknown option "^.*pdf/}}'"
What syntax am I missing here?
Upvotes: 3
Views: 2706
Reputation: 626689
You may use
--query "{ 'copysheet': { '$regex': '^.*pdf', '$options':'' }}"
The point is that you should pass the data to the query
argument as JSON.
See reference:
--query <JSON>, -q <JSON>
Provides a JSON document as a query that optionally limits the documents returned in the export. Specify JSON in strict format.
Note: on different systems, you might need to swap single with double quotes.
Upvotes: 7