-
Notifications
You must be signed in to change notification settings - Fork 4
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
Allow empty string prefix separator #1
base: master
Are you sure you want to change the base?
Conversation
Glad you find this useful! The only real thing wrong with the library (which I haven’t had time to think through yet) is the annoying requirement to manually recompile the dep when you add/change your desired config - curious if you ran into this and if you have any suggestions on that front... |
I have to look into your solution more closely - if there isn’t a separator we’d have to make assumptions that the module identifier is always single character? I’m not against this it just might bite you down the line... thoughts? |
Ah! Yes—ran into it but I don't have too much experience writing Elixir libraries so steered clear. My gut instinct was that using On multi-character identifiers... I had not thought of that; definitely could be a gotcha. How does Module naming work with that currently, with respect to capitalisation? I must admit I was a little confused about how a prefix |
The idea is that you have your domain model - MyApp.User - let’s say you want to have the ID not be sequential; you’d choose a prefix for it; probably “u”. So if there wasn’t a separator you’d have an ID like u[hash]. So as long as the library can assume if separator is “”, the first letter is always the module. This is fine for small apps, but the moment you have 30 models in your app, you’ll regret the decision. What’s the reason for not wanting a separator? If it’s aesthetic, you might just strip the separator when displaying it? |
Yeah good call. And yes, aesthetic. My initial plan (again, just for
aesthetics) was to have 6-digit alphanumeric hashes that included caps and
lowercase characters without any prefixing or to get clean urls like: `
myapp.org/projects/n32Sn1/jobs/x9GGde`. Ditching the prefix with this
implementation obviously doesn't work as it's doing lots of the magic :-)
…On Sat, Dec 12, 2020 at 8:17 PM Greg Coladarci ***@***.***> wrote:
The idea is that you have your domain model - MyApp.User - let’s say you
want to have the ID not be sequential; you’d choose a prefix for it;
probably “u”. So I’d there wasn’t a separator you’d have an ID like
u[hash]. So as long as the library can assume if separator is “”, the first
letter is always the module. This is fine for small apps, but the moment
you have 30 models in your app, you’ll regret the decision.
What’s the reason for not wanting a separator? If it’s aesthetic, you
might just strip the separator when displaying it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCUBLJ76ZPRGONPYARYD33SUQI33ANCNFSM4UY3SPBA>
.
|
Yeah I would say just preprocess the ID on the way out and then manually
add my back in on the way in; this allows your controllers to own the
“assumptions” that the given ID is of type X, in both directions. This also
allows you to change your mind at any point..
On Sun, Dec 13, 2020 at 8:53 AM Taylor Downs <[email protected]>
wrote:
… Yeah good call. And yes, aesthetic. My initial plan (again, just for
aesthetics) was to have 6-digit alphanumeric hashes that included caps and
lowercase characters without any prefixing or to get clean urls like: `
myapp.org/projects/n32Sn1/jobs/x9GGde`
<http://myapp.org/projects/n32Sn1/jobs/x9GGde>. Ditching the prefix with
this
implementation obviously doesn't work as it's doing lots of the magic :-)
On Sat, Dec 12, 2020 at 8:17 PM Greg Coladarci ***@***.***>
wrote:
> The idea is that you have your domain model - MyApp.User - let’s say you
> want to have the ID not be sequential; you’d choose a prefix for it;
> probably “u”. So I’d there wasn’t a separator you’d have an ID like
> u[hash]. So as long as the library can assume if separator is “”, the
first
> letter is always the module. This is fine for small apps, but the moment
> you have 30 models in your app, you’ll regret the decision.
>
> What’s the reason for not wanting a separator? If it’s aesthetic, you
> might just strip the separator when displaying it?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <
#1 (comment)
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/ACCUBLJ76ZPRGONPYARYD33SUQI33ANCNFSM4UY3SPBA
>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHVFB6U6HSDN2DRVAR5OJDSUTWPLANCNFSM4UY3SPBA>
.
|
Makes sense. Thank you :-)
On Sun, Dec 13, 2020 at 12:16 PM Greg Coladarci <[email protected]>
wrote:
… Yeah I would say just preprocess the ID on the way out and then manually
add my back in on the way in; this allows your controllers to own the
“assumptions” that the given ID is of type X, in both directions. This also
allows you to change your mind at any point..
On Sun, Dec 13, 2020 at 8:53 AM Taylor Downs ***@***.***>
wrote:
> Yeah good call. And yes, aesthetic. My initial plan (again, just for
> aesthetics) was to have 6-digit alphanumeric hashes that included caps
and
> lowercase characters without any prefixing or to get clean urls like: `
> myapp.org/projects/n32Sn1/jobs/x9GGde`
<http://myapp.org/projects/n32Sn1/jobs/x9GGde>
> <http://myapp.org/projects/n32Sn1/jobs/x9GGde>. Ditching the prefix with
> this
> implementation obviously doesn't work as it's doing lots of the magic :-)
>
> On Sat, Dec 12, 2020 at 8:17 PM Greg Coladarci ***@***.***
>
> wrote:
>
> > The idea is that you have your domain model - MyApp.User - let’s say
you
> > want to have the ID not be sequential; you’d choose a prefix for it;
> > probably “u”. So I’d there wasn’t a separator you’d have an ID like
> > u[hash]. So as long as the library can assume if separator is “”, the
> first
> > letter is always the module. This is fine for small apps, but the
moment
> > you have 30 models in your app, you’ll regret the decision.
> >
> > What’s the reason for not wanting a separator? If it’s aesthetic, you
> > might just strip the separator when displaying it?
> >
> > —
> > You are receiving this because you authored the thread.
> > Reply to this email directly, view it on GitHub
> > <
>
#1 (comment)
> >,
> > or unsubscribe
> > <
>
https://github.com/notifications/unsubscribe-auth/ACCUBLJ76ZPRGONPYARYD33SUQI33ANCNFSM4UY3SPBA
> >
> > .
> >
>
> —
> You are receiving this because you commented.
>
>
> Reply to this email directly, view it on GitHub
> <
#1 (comment)
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAHVFB6U6HSDN2DRVAR5OJDSUTWPLANCNFSM4UY3SPBA
>
> .
>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCUBLM6ECV2FIPQWMJCB23SUTZFLANCNFSM4UY3SPBA>
.
|
Not sure if this has come up before, but I'd love to not use a prefix separator... does this do the trick? Really cool implementation of hashids, btw. Thank you.