0

We are planning to upload Image only available for selected users. Here we have store the Image with visible users list in MuSql database.

At the same time consider a mobile API (Node JS), In that we have to fetch the all list of image urls that are visible for some random list of users (Users list from API request body). The image urls that are shown should be available only for the users in the request. The images that are not visible for the requested users should not be shown in the response list.

Please help us with how we have to setup the table and its columns in order the achieve the functionlaity.

We have tried adding a column users_list of JSON type to the table. With this we have made loop with requested users list with the users_list in the table. The difficulty is that when the requested users list very long then the loops gets more time execute.

Is there any way to fetch the images list that are available for requested users using MySql query without looping.

  • Storing the images themselves in MySQL will harm performance badly. Store the images on disk, or something like an S3 Bucket. Only store the path to the image in MySQL. If possible, put the images in the web server's normal assets directory and allow it to serve the image as normal URL. – Schwern Dec 12 '22 at 19:56
  • Would you please show the code you're using to retrieve the images, and your table schema? – Schwern Dec 12 '22 at 19:57

0 Answers0