Import json Mongodb

So i imported a json file with

mongoimport -d mydb -c mycollection --jsonArray < glossary.json
the problem is that _id is stored as string in Db and not as an ObjectID

Like this

enter image description here

So when i try to execute findbyId/findOne({_id:id}) request i get a null as a result
I’ve tried the solution with findOne({ _id: new ObjectID(id) } but it didn’t work for me

PS: the _id in the json file is a string also
is there is any way to convert _id from string to objectId or any other solution

Sorry if the question is duplicate

Leave a Comment