Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

312
Views
Using JavaScript, how can I pull info from a database and order it in a list?

I have a rough idea on how to do this, but it doesn't seem to be working too well.

What I have already achieved is pulling all of the data necessary that needs ordered. What I need is a way to take all of that information and order it from the highest number to the lowest number, and then display that in a single embed - without the use of adding more fields. Ideally it should look something like the image included, except inside an embed. I want to be able to loop this so that it automatically updates the message every X amount of seconds with a message edit.

Each row is ordered from #1 to #20 with #1 having the most Points. This is in the [0123] bit.

The code used to select data from the table is:

const [team, teamd, teame] = await pool.query("SELECT * FROM `performancetracker`.`leaderboard`");

The columns I have use for are TeamName and Points.

I've done something similar with the following code:

      Object.keys(check).forEach(function(key) {
    var row = check[key];
    let name = row.TeamName
  embed1.addField(`Team:`, `${name}`, true)
  })

However, this adds fields to the embed, which I don't want. I'm not too sure how to go about creating an array or object that I can add to and edit later in the code while maintaining the ability to add it as a field in an embed. I'm not fluent with JavaScript, I'm still learning new things and finding new challenges.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm not sure I can help you with the updating part because I don't fully understand the question, but you can do this for displaying the embed how you want:

let data;
Object.keys(check).forEach(() => {
    var row = check[key];
    let name = row.TeamName
    data += `Team: ${name}\n`
})
embed1.addDescription(data)

I haven't tested this code, but it should work.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!