How to query a database?

I want to create an intranet solution using Wix. The basic structure of the site has one page with 20 upload button and 20 pages with 1 download button. An admin user will have access to upload page and download pages and other members (employees) will have access to one page each so they can download objectives uploaded by the admin for them. I have the upload button linked to a database, but I am not sure how I will link each file to the corresponding member and refresh the download button every week. I think I need to make a query at the download pages but I have 0 knowledge of coding in JS or Wix. Kindly help, thanks in advance.

Use Wix-Data from VELO-API (EXAMPLE)…

import wixData from 'wix-data';

let myDatabase = "type in DATABASE-ID here";

$w.onReady(()=>{
    wixData.query(myDatabase)
  .find()
  .then((res) => {console.log(res);
    if(res.items.length > 0) {
      console.log(res.items[0]); //see item below
    } else {
      // handle case where no matching items found
    }
  })
  .catch((err) => {console.log(err);});
});


Thanks a lot for replying! Do I need to paste it in the console of every page with a download button for it to work? I appreciate your help a lot.

Not enough INPUT regarding your project-description.

You are talking about several pages, i would say, you should first start to create/generate a good structured DATABASE.

Every good designed and coded Website, has a DATABASE working in BACKGROUND!

And about → Working with TIMES and DATES, take a look here…

This post also could be useful for you…