Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Creation time guessed from ObjectID #55

Closed
heruan opened this issue Nov 14, 2012 · 2 comments
Closed

Creation time guessed from ObjectID #55

heruan opened this issue Nov 14, 2012 · 2 comments
Labels

Comments

@heruan
Copy link

heruan commented Nov 14, 2012

I noticed that the document's creation time displayed is guessed in Genghis by parsing the ObjectID, since a default MongoDB ObjectID has the first 4 bytes representing the timestamp the ObjectID was created at.
It may be a nice feature, but one can use custom values in ObjectIDs resulting in awkward dates displayed in Genghis:

Genghis
2 documents
==========
7b694dc93a35bb44f4d31124 Sun, 12 Aug 2035 02:32:41 GMT
{
  _id: ObjectId("7b694dc93a35bb44f4d31124"),
  ...
}
0862b01e825494dc728b437e Mon, 17 Jun 1974 07:15:42 GMT
{
  _id: ObjectId("0862b01e825494dc728b437e"),
  ...
}

Can this behaviour be disabled in cases where the guess would be wrong?

@bobthecow
Copy link
Owner

Yep, this is weird. I'd like to support this use case, but I'd also love to avoid adding a setting to support it, so what would be a reasonable heuristic for deciding whether to show a creation timestamp?

@bobthecow
Copy link
Owner

Here's the heuristic I settled on:

  • Only guess creation date if all documents in the current page of the current collection which have ObjectIds as their _id also have "sane" ObjectId timestamps
  • A "sane" ObjectId timestamp is a timestamp timestamp created from the first four bytes of the ObjectId which is before 48 hours from now (leaving some room for time zones and server timestamp craziness?) and after the release of Mongo v1.0.

This change has been committed to develop and will be in the next release!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants