In my project, on of the requirements is to generate 7 digit alphanumeric code for every transaction user does.
One user can be part of multiple organisations and for every new transaction that user does in any of the organisations we want to generate 7 digit alphanumeric non-repeating code.
Implementation:
Every time we generate a new code we don't want to check in the database whether that id existed or not because that will not scale.
we want to have a function which if we call n number of times will return n number of unique codes or any other implementation also works fine.
I've tried to research on how git generates 7 digit unique sha inside the project without any success,
Any kind of help pointing to resources or boilerplate code is really appreciated.
If it helps we are using node.js
and mongodb
in our backend.