Error importing JSON data involving timestamps and objectIDs

Ok so below is an image showing the “new” and “old” object ID and timestamp format mongodb uses. Old is referring to the imported json data and new is referring to data i have created.
1657996183328
Now the main issue i have with this difference is that i cannot ammend the imported data but i can created new data and read the imported - And i believe the reason is because the imported data for some reason doesn’t have the ObjectId() or ISODate() functions just the string.

So i want to find a way to add those or import it such that it imports usable - and yes, I have already tried manually adding ISODate() and ObjectId then reimporting it to match the new data, that just throws JSON errors and doesnt properly import.

Thanks!

For added clarification*

I imported a json file that contained my mongodb database using a mongoimport --collection jsons --jsonArray -d main -v databasemain.json command.
The old is the imported data new is created data
I cannot edit or add to the imported data

it would be better if you included those JSON error messages so to tell what is wrong.

_id field is not required to be a proper ObjectId to insert the data, as your updatedAt field not being a Date. it will just be a bit different to index that document. You may try importing your data to a temporary collection, then use other query methods to change these strings into proper ObjectId and Date formats to insert into a new collection, then drop the old one.

I fixed it by removing and reinserting all of the data

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.