ottobar
ottobar

Reputation: 4361

Are default _id fields for MongoDB documents always 24 hex characters?

As part of my application requirements, I have a limit of 30 characters for an ID field. This is out of my control and I am wondering if the MongoDB default _id fields will work for me. It appears as though the default _id field is 24 characters long. That works for me, but I am wondering if this is likely to change in the future. I am well aware that things can always change, but, for the next year or two, can I expect there to be 24 character default _id fields?

Upvotes: 9

Views: 6670

Answers (1)

mdirolf
mdirolf

Reputation: 7651

They aren't actually 24 characters - they are 12 bytes (24 characters in hex representation). And yes, that will be the case for the foreseeable future.

Upvotes: 20

Related Questions