Convert Meteor mongo string _id into ObjectId

I have a problem with one of my collections. I forgot to add the date when the document was inserted but now need it.

Standard MongoDB ObjectIDs are based on the timestamp where the ObjectId has a method that lets you determine the timestamp

var id = new ObjectId();

unfortunately Meteor and MiniMongo don’t use ObjectIds but strings as _id. Those strings are not the hexadecimal string representation of the MongoDB ObjectId, but something else.

Does anybody know how to reverse engineer the MiniMongo string id so I can determine the timestamp when the document was inserted?

Unfortunately, the minimongo string is a randomized hash. There’s no embedded timestamp.

You can use the {idGeneration: "MONGO"} flag on collections to use ObjectIds instead; which works fine on everything EXCEPT the user accounts.

Thank you, I just found my answer in the docs as well

ObjectID values created by Meteor will not have meaningful answers to their getTimestamp method, since Meteor currently constructs them fully randomly.

You might be able to do some detective work by investigating the oplog and trying to determine the datestamp information from those entries.