Sequeilize find highest value of table in where clause

131
August 17, 2019, at 08:00 AM

I have a Table called Seasons where columns are "start_at" and "end_at". these columsn contain year values like 2019 and 2020 and so on. I want to update one row which has the highest value in "end_at" column. I tried something like this:

Season.update({is_current: 0}, {where: {is_current: 1}})) 
.then(() => Season.update({is_current: 1}, { 
    where: sequelize.where( 
        sequelize.fn("MAX", sequelize.col("end_at")) 
    ) 
}))

But it gives me an error:

Error: Invalid use of group function

Can somebody help me?

Rent Charter Buses Company
READ ALSO
Javascript why is object property ok in header script but undefined in html?

Javascript why is object property ok in header script but undefined in html?

The first alert displays correctly "hello" at load time, but when I click on the button, the alert displays "undefined" for exactly the same property

153
insert html table data into mysql database in node js

insert html table data into mysql database in node js

I am trying to retrieve data from a html table and insert this in MySQL databaseI am already able to do the reverse, which is retrieve the information from the database and display it in same table using ejs template

205
How can I avoid using hardcoded credentials in Javascript

How can I avoid using hardcoded credentials in Javascript

I am working on a Javascript application in which a password has been hardcoded ie var key ='333666'

140
cypress: comparing information in 2 sites

cypress: comparing information in 2 sites

I'm starting with cypress and need to compare 2 different environments

234