Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data restored from mongodb dumb throwing bson error on _id field #9847

Closed
Safvan-tsy opened this issue Feb 28, 2024 · 1 comment
Closed

data restored from mongodb dumb throwing bson error on _id field #9847

Safvan-tsy opened this issue Feb 28, 2024 · 1 comment
Labels
Data export We export data nightly as CSV, MongoDB… See: https://world.openfoodfacts.org/data MongoDB We have 2 mongodb collections: one for current products, and one for obsolete products

Comments

@Safvan-tsy
Copy link

Safvan-tsy commented Feb 28, 2024

Downloaded MongoDB dump from https://world.openfoodfacts.org/data

Im using the below command to take the data to my db
mongorestore -h localhost:27017 -d db-name /off/dump/products/

products folder has these two files : products.bson and products.metadata.json
After restore the value of _id is not coming as type of mongodb Objectid . its a string eg: _id: "0000000000"

I want the _id to be type of mongodb ObjectId

@stephanegigandet
Copy link
Contributor

@Safvan-tsy We use a string (the barcode) for the _id field.

See https://www.mongodb.com/docs/manual/core/document/

"The field name _id is reserved for use as a primary key; its value must be unique in the collection, is immutable, and may be of any type other than an array."

@teolemon teolemon added MongoDB We have 2 mongodb collections: one for current products, and one for obsolete products Data export We export data nightly as CSV, MongoDB… See: https://world.openfoodfacts.org/data labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data export We export data nightly as CSV, MongoDB… See: https://world.openfoodfacts.org/data MongoDB We have 2 mongodb collections: one for current products, and one for obsolete products
Projects
None yet
Development

No branches or pull requests

3 participants