1

Possible Duplicate:
mongoexport without _id field

How do I remove the _Id field when using mongoexport?

$ ./mongo
MongoDB shell version: 2.2.2
connecting to: test
> db.coll.insert( {first: "John", last: "Doe"} )
> exit
$./mongoexport --db test --collection coll --out out.json --fields 'first,last'

out.json:

{ "_id" : { "$oid" : "50bc20b3cef5182e2a788fc9" }, "first" : "John", "last" : "Doe" }

instead of:

{ "first" : "John", "last" : "Doe" }

Community
  • 1
  • 1
pent
  • 31
  • 1
  • 2
  • Maybe not what you are looking for, but exporting in csv format exclude the "_id" field. – Eric Dec 03 '12 at 06:12
  • mongo / --quiet --eval "db..find({}, {_id:0,:1}).forEach(printjson);" > out.txt If you have some query to execute change `""` to `''` and write your condition in `find` with `""` like `find("age":13)`. – xring Jan 20 '16 at 03:07

0 Answers0