From Perplexity AI:
Q: Is there a known bug where the Meteor generated ObjectIDs do not have the correct date?
A: Yes, there is a known issue in Meteor where ObjectIDs generated by Meteor do not always have a meaningful or correct timestamp in their getTimestamp()
value. This is because Meteor’s implementation of Mongo.ObjectID
(when using { idGeneration: 'MONGO' }
) historically generated ObjectIDs with random values, rather than encoding the current date and time as MongoDB’s native ObjectId does[5].
ObjectID values created by Meteor will not have meaningful answers to their getTimestamp method, since Meteor currently constructs them fully randomly.[5]
This means if you use Meteor’s Mongo.ObjectID
to generate _id
values, calling .getTimestamp()
on those IDs may return a timestamp that does not correspond to the actual creation date of the document, and could even appear as a date far in the past or future.
Summary:
- Meteor-generated ObjectIDs may not encode the correct creation timestamp.
- This is a result of Meteor’s ObjectID implementation, not a bug in MongoDB itself.
- If you need accurate timestamps, use a separate date field (e.g.,
createdAt
) in your documents[5].
If you require ObjectIDs with correct timestamps, consider generating ObjectIds on the server using MongoDB’s native mechanism or always storing an explicit timestamp field.
Does this make sense??
I switched to ObjectIDs so I could drop the exact createdAt
field and indexes I use in a lot of collections, and I can confirm the ObjectIDs do not encode a correct timestamp.