문제

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