You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a route /social/:user_id and which renders a Blaze template which depends on FlowRouter.getParam('user_id').
I'm now on the process of making an alias to this route by using /:username instead of /social/:user_id
The problem here is that when I receive the username via URL, for instance mysite.com/britneyspears i have to do an _id lookup to find the user_id based on username
Once i fetch the user_id i would like to render my old route, /social/:user_id by doing something similar to:
But without changing the URL, this way the username only works as a "mask" to the end-user but the rest of my application can rely on
FlowRouter.getParam('user_id')
so it's actually the username "mask" is transparent for the client and for the backend side.
Other option would be to accept "username" instead of user_id in most places, but that would require the whole application to have some sort of "findIdByUsername" in a lot of places which would increase the number of queries my application do.
But this won't work, because user_id param doesn't exist on the route FlowRouter doesn't allow me to set it! One solution would be to do something like:
The route will change to /username/mongo_db_id which is very unfriendly to the user and won't allow me to do user-friendly routes like /:username/followers and so on.
What am I doing wrong? Would be much simpler for my application if I could just make the user_id work transparently so I won't have to deal with username everywhere.
The text was updated successfully, but these errors were encountered:
/social/:user_id
and which renders a Blaze template which depends onFlowRouter.getParam('user_id')
./:username
instead of/social/:user_id
The problem here is that when I receive the
username
via URL, for instancemysite.com/britneyspears
i have to do an _id lookup to find theuser_id
based onusername
Once i fetch the
user_id
i would like to render my old route,/social/:user_id
by doing something similar to:But without changing the URL, this way the username only works as a "mask" to the end-user but the rest of my application can rely on
so it's actually the username "mask" is transparent for the client and for the backend side.
Other option would be to accept "username" instead of user_id in most places, but that would require the whole application to have some sort of "findIdByUsername" in a lot of places which would increase the number of queries my application do.
Another solution i tried was to set user_id param
But this won't work, because
user_id
param doesn't exist on the route FlowRouter doesn't allow me to set it! One solution would be to do something like:and then render, my template wouldn't even know what's happening!
And if i add the 'user_id' to the route, for instance:
The route will change to
/username/mongo_db_id
which is very unfriendly to the user and won't allow me to do user-friendly routes like/:username/followers
and so on.What am I doing wrong? Would be much simpler for my application if I could just make the user_id work transparently so I won't have to deal with username everywhere.
The text was updated successfully, but these errors were encountered: