mongodump can use the -q option to limit the documents dumped to a query pattern. However, the results can't be "shaped" with a projection the way a normal query can be. In the absence of SERVER-14880 or SERVER-14881, the only usable option is to iterate the query cursor client-side, and then either
- insert the documents into some other database, dump it, and then drop it, or
- just printjson the results from inside --eval and redirect stdout to a file.
This could apply to mongoexport --fields as well.
Update: consider the possibility of negative projection (aka blacklist) as well, as mentioned in
TOOLS-2313. Perhaps we should take a full projection document as Extended JSON?