Replacing ObjectID's in MongoDB with pure strings

226 Views Asked by At

I have a MongoDB database which generates ids with type ObjectID.

I think I often have problems with the ObjectID type when comparing them with strings, outputting them as JSON, etc.

Also, I think they are very ugly when I visit a user profile /users/59aed0f8f25c0f0ca8f94aad.

Therefore, I thought if it's possible (and clever) to avoid using ObjectID? I really like the length of, for instance, YouTube and IMDb IDs, so I thought about finding an algorithm to create such IDs instead.

But will there be any problems not using ObjectID? I have never really understood why they are not just strings, but I'm wondering whether they are there for either some optimization reason or backtracing when the ID was generated or something like this?

0

There are 0 best solutions below