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

198
Views
Using Sequelize load data of every hour of a day

how to load record of transactions of every hour.

if (ExpenseGraphTimeSeries === 'today') {
        let date = new Date(Date.now());
        let createdAt = {
          [Op.lt]: new Date(date),
          [Op.gte]: new Date().setHours(0, 0, 0, 0)
        };

        ExpenseGraphCondition.createdAt = createdAt
        ExpenseGraph = await model.Expense.findAll({
          where: createdAt,
          attributes: [
            [model.sequelize.fn('sum', model.sequelize.col('Amount')), 'expense'], 'createdAt'
          ],
        });
      }

Current out put is
| Amount | createdAt | | -------- | -------------- | | 2349 | 01-01-2020 00:00:00 | | 2349 | 02-01-2020 00:00:00 |

i need record of every hour with amount of that hour. how to do this? 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

group:[] is use in sequelize to return data by groups. your code will be like this

    if (ExpenseGraphTimeSeries === 'today') {
        let date = new Date(Date.now());
        let createdAt = {
          [Op.lt]: new Date(date),
          [Op.gte]: new Date().setHours(0, 0, 0, 0)
        };

        ExpenseGraphCondition.createdAt = createdAt
        ExpenseGraph = await model.Expense.findAll({
          where: createdAt,
          attributes: [
            [model.sequelize.fn('sum', model.sequelize.col('Amount')), 'expense'], 'createdAt'
          ],
          group: [model.sequelize.fn('hour', model.sequelize.col('createdAt'))],
          order: [['id', 'asc']], //optional
        });
      }

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!