MongoDB: ObjectId Tricks
John Nunemaker shares a couple of tricks using MongoDB ObjectID:
Where it gets even more interesting is that you can also create object id’s from time. This means you can use object id’s in range queries
The good part is that there is a clear MongoDB’s specification for ObjectID and this will guarantee that using these tricks will not break your code over time:
A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp (seconds since epoch), a 3-byte machine id, a 2-byte process id, and a 3-byte counter. Note that the timestamp and counter fields must be stored big endian unlike the rest of BSON.
Original title and link: MongoDB: ObjectId Tricks (NoSQL databases © myNoSQL)