It seems like you are searching for the minimum value and according to information found in the official documentation:
const sequelize = require('sequelize');
Art.find({
attributes: [
[sequelize.fn('min', sequelize.fn('date_part', 'year', sequelize.col('date'))), 'minimumYear']
]
});
The model Art
is associated with your "Arts" table, where the field date
represents the "date" column.
By utilizing the attributes
option, you can specify the functions or columns you wish to select. In this scenario, using sequelize.fn
is essential to define the function date_part
with the parameter 'year'
before applying it to the date
column.