AFAIK mongodump does not support projection. You can use mongoexport:
mongoexport -d my_database -c my_collection --fields id
Pergunta
I'm trying to dump all values of just one field (id
) in a particular collection using mongodump
. I.e. the same as returned by this query:
db.my_collection.find({},{id:1})
I'm trying
mongodump -d my_database -c my_collection -q -q "{},{id:1}"
When I do this, it dumps all fields.
Another question has suggested
mongodump -d my_database -c my_collection -f id
But it looks like that flag has been removed because
ERROR: unknown option -f
Solução
AFAIK mongodump does not support projection. You can use mongoexport:
mongoexport -d my_database -c my_collection --fields id