سؤال

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
هل كانت مفيدة؟

المحلول

AFAIK mongodump does not support projection. You can use mongoexport:

mongoexport -d my_database -c my_collection --fields id
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top