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

Id length is actually max-length #55

Closed
icetbr opened this issue May 7, 2018 · 3 comments
Closed

Id length is actually max-length #55

icetbr opened this issue May 7, 2018 · 3 comments

Comments

@icetbr
Copy link

icetbr commented May 7, 2018

Hi, your concern seems to be only with key collisions, which is fine. But I also want (visual) uniformity. I would suggest to make the length the exact same size as requested.

Thanks

@ai
Copy link
Owner

ai commented May 8, 2018

@icetbr So you have a different ID length on different calls? Can you show how do you use Nano ID?

@icetbr
Copy link
Author

icetbr commented May 8, 2018

Oh, that was unintentional? I will try to find out what's wrong then, because I can't reproduce this locally I ran 1 million calls and all the same length.

I had just changed the code from shortid to nanoid, maybe something got cached or didn't restart properly.

I'll have to wait for my production server to go under intense load again.

To answer your question, I have a utils.js

const nanoid = require('nanoid');

module.exports = {
    shortId() {
        return nanoid(10);
    }
}

@ai
Copy link
Owner

ai commented May 8, 2018

nanoid(10) will always generate 10 symbols ID
https://github.com/ai/nanoid/blob/master/index.js#L25

I think you had a cache problems

@ai ai closed this as completed May 8, 2018
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

2 participants