Skip to content

Instantly share code, notes, and snippets.

@gianpaj
Created April 8, 2021 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gianpaj/df6470cb24f82659580200828f6873bc to your computer and use it in GitHub Desktop.
Save gianpaj/df6470cb24f82659580200828f6873bc to your computer and use it in GitHub Desktop.
db.export_without__id.insert({a:1})
db.export_without__id.insert({a:2})
db.export_without__id.insert({a:3, something_id: 'name'})
db.export_without__id.find().pretty()
{
  "_id": ObjectId("606ee1c03557e533795e426f"),
  "a": 1
}
{
  "_id": ObjectId("606ee1c23557e533795e4270"),
  "a": 2
}
{
  "_id": ObjectId("606ee1d93557e533795e4271"),
  "a": 3,
  "something_id": "name"
}
mongoexport --db test --collection export_without__id | sed '/"_id":/s/"_id":[^,]*,//'

2021-04-08T12:02:25.377+0100	connected to: mongodb://localhost/
2021-04-08T12:02:25.379+0100	exported 3 records
{"a":1.0}
{"a":2.0}
{"a":3.0,"something_id":"name"}

Still there ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment