Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate just alphanumeric unique ids? #146

Open
Aman83770 opened this issue Aug 1, 2019 · 3 comments
Open

How to generate just alphanumeric unique ids? #146

Aman83770 opened this issue Aug 1, 2019 · 3 comments

Comments

@Aman83770
Copy link

shortid required 64 unique characters. For this, I have to add two special characters, thus id will have a special character. Is there any option I can generate only alphanumeric unique id?

@ashoksahoo
Copy link

You do a loopity loop (recursion) until you generate one with those characters.


function customGen() {
    s = shortid.generate()
    if (isvalidForMe(s)) {
        return s
    } else return customGen()
}

@sostenesg7
Copy link

You do a loopity loop (recursion) until you generate one with those characters.


function customGen() {
    s = shortid.generate()
    if (isvalidForMe(s)) {
        return s
    } else return customGen()
}

Don't do it!
This can cause infinite loop if the new code always contains special characters.

@ashoksahoo
Copy link

You should use nanoid, I moved to nano id after, shortId didn't worked out for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants