[SERVER-9025] [suggestion] Expression for "_id" generation. Created: 19/Mar/13  Updated: 10/Dec/14  Resolved: 20/Mar/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Kostyantyn Rybnikov Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Mongo has a interop mechanism between replica members that lets it generate unique _id easily. But when our application wants to create an _id that starts with user_id, it becomes much harder to keep uniqueness.

I'd like to suggest to add a mechanism to be able to set an _id generation for collection as some sort of template that would look like (in my case with user_id upfront) "

{id} {mongoid}

", that would put my id (which is just user_id) and then mongo-generated one. Possibly more parameters could be added to make it more flexible.

What do you think?



 Comments   
Comment by Kostyantyn Rybnikov [ 19/Mar/13 ]

Sorry, I can see that drivers are generating machine_id themselves

machine_hash = _md5func()
machine_hash.update(socket.gethostname())
return machine_hash.digest()[0:3]

which I didn't know (I don't know why, but I always thought that _id's are generated on server-side and guarantee uniqueness via guaranteed uniqueness of machine-id somehow).

So I guess you can close this bug since _id's with this level of guarantees are also easy to generate on client-side.

Generated at Thu Feb 08 03:19:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.