Friendly pix demo

475 views
Skip to first unread message

Ely Ochola

unread,
May 20, 2016, 10:18:02 AM5/20/16
to Firebase Google Group
Hi Guys,

I'm pretty new to Firebase and love what i've seen so far! I was looking to use the FriendlyPix demo as a starting point for my web app. one thing I wanted to do was view a user by their username via the url rather than the UID.

I was hoping to use a url structure like https://friendly-pix.com/user/UserName

Could anyone point me in the right direction?

Many thanks!

Tom Larkworthy

unread,
May 20, 2016, 2:52:54 PM5/20/16
to Firebase Google Group
So when you visit user/XXX the router calls loadUser:


loadUser uses the input param to set the user_id

you could use the param to perform a query in firebase to map between a username and user_id

Although the consequence of that is that each username will have to be unique. Facebook makes user friendly user_ids by appending numbers to the basic name. So you would need to do something like check for collisions of usernames before assigning one.


I think I would introduce a new lookupByUsername, which will utilize something similar to the existing searchUsers functionality to find a user record by name https://github.com/firebase/friendlypix/blob/a1437c89db34aa330c3d667e4559302f1540007b/web/scripts/firebase.js#L324

I'd then change loadUser to use lookupByUsername instead of lookupUser

The fact usernames would have to be unique is awkward and would need some work to get right though.

Tom 


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/c3a2cc1c-aca4-49fe-baea-87f2066179e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages