Need help on data analysing

Hi hope someone can help me. I have 2 Database ( Members and Friends). In each database, I have the same field (Firstname, Lastname,Email,Picture)
I am looking for a bit of code help here. Here is what I need.

I have a button called Profile. On click of this button, I need to know in what database the active user is register. (The active user can be register in only 1 of the 2 database) I need to do a simple script on getting the active userID, then search in database Members to see if it exist, if not than look in the other database, etc…
Once the code find in what database the user is created, I just need to forward the user to the proper page ( For Members, wixLocation.to(/Members/${wixUsers.currentUser.id}); or for Friends, wixLocation.to(/Friends/${wixUsers.currentUser.id});

Hope someone can help me :slight_smile:

thanks a lot

Hi,

since both members and friends has the same data points (Firstname, Lastname,Email,Picture) and you need to search both (and might be more in the future), i’d advise you to consolidate it to a single collection called ‘users’ and add a new column which will be called user_type in which you will add the value ‘friend’ or ‘member’ then query this single collection and by the result you find forward the user to wixLocation.to (/' + result.user_type + '/${ [wixUsers.currentUser.id](http://wixusers.currentuser.id/) });

hope it makes sense, good luck!
Shlomi

Ok let’s say I want to use your method, what would be the code to search in my database please ? :slight_smile:

Hi,

You can see a step-by-step article for creating member pages here .
It includes example code for querying a member collection.