user1130217
user1130217

Reputation:

possible mongodb driver bug?

I was playing around with mongodb on PHP and I noticed something strange, look at these:

{ "_id" : ObjectId("4f08958fd80aa8cf6d000000"), "nickname" : "alex" }
{ "_id" : ObjectId("4f089669d80aa8cd6d000000"), "nickname" : "franz" }
{ "_id" : ObjectId("4f0896b3aaca83b3c256b6b4"), "nickname" : "sergej" }

notice the _id, in the first two the last 6 numbers, which should be randomly generated, are all zeroes, those two are the ones I created on a php page, the last one I created directly from mongo interface.

Now, I know the id is already unique enough but on production this is going to be a problem, do you know if this is a bug or maybe there's a workaround this?

Thanks in advance.

Upvotes: 0

Views: 78

Answers (1)

Eve Freeman
Eve Freeman

Reputation: 33155

It is only a random number if an incremented value will not work.

See the BSON ObjectID Specification section: http://www.mongodb.org/display/DOCS/Object+IDs

Upvotes: 1

Related Questions