Complicated process to show images when a certain user is logged in

I am trying to create a page on my site that will allow logged in users to be shown certain images [or possibly dynamic page links] based on their credentials.

My current process:

  • I have 5 or so DB’s that contain information about people in an org (name, email, team, etc…). Yes, they need to be separate DBs. I will refer to these as peopleDBs.
  • I have 1 DB that stores images for every team in the org, in a key:value scheme (ie teamName: image). I will refer to this as imageStoreDB.

I have read Site Members: About the Member's Area | Help Center | Wix.com and https://www.wix.com/code/home/forum/community-discussion/show-element-when-certain-user-is-logged-in .
These seem to give me a good start since it allows me to get the email address of a logged in user.
However for my process, I will first need to check this email address against a single peopleDB.
Then IF the email address is found in the peopleDB, check that row to see what team the user is on.
Finally, I need to pull a specific image from the imageStore DB based off of the team the current user is on (basically a foreign key).
I will then need to repeat this process for each peopleDB I have.

So question #1, what would be the best way to go about this? I’ve seen https://www.wix.com/code/reference/$w.Text.html#show but am not sure exactly how to incorporate it into my situation.
Question #2, would optimization be a problem? In my case I would have no more than 1000 rows TOTAL spread across all DB’s.

Any help/design ideas/critiques are welcomed. I do have programming experience, however not is JS, but if JS is the only way to achieve this then that is fine, just no preferable.

I hope I explained that well. Thank you advance.

Hello

You will need to do ,multiple queries:

  • Query people DB to get the team (based on the user’s email)

  • Query imageStore Db to get the image/s corresponding to the team

  • Set the image element source to the query result using code

Here’s A code Example of how it would be done:

let EmailResults = await wixData.query('peopleDB')
        .eq("emailField", 'user-email').find()
 let team = EmailResults.items[0].teamField
 
 let ImageResult = await wixData.query('imageStore')
        .eq("teamField", team).find()

 let imageSrc = ImageResult.items[0].imageField

 $w('#image').src = imageSrc

Her’s some links to guide you through: