Answer the question
In order to leave comments, you need to log in
How to filter an array in sequelize?
In the database I have a table with columns "start_date", "end_date" and other columns. But I need "start_date", "end_date" data.
This is how I query data from a table:
const getStartEndDateInTradePage = require('../models/Trades');
module.exports.getStartEndDateInTradePage = async (req, res) => {
try {
const arr = await getStartEndDateInTradePage.findAll(
{
attributes: ['open_date', 'close_date']
}
)
res.status(201).json(arr);
} catch (e) {
console.log(e)
res.status(500).json({
message: 'Server ERROR!'
})
}
}
[
{open_date: "2002-07-30", end_date: "-"},
{open_date: "2002-07-30", end_date: "2002-09-06"},
{open_date: "2002-07-30", end_date: "-"},
{open_date: "2002-07-30", end_date: "2002-09-06"},
{open_date: "2002-09-06", end_date: "2002-12-06"},
{open_date: "2002-09-06", end_date: "-"},
{open_date: "2002-09-06", end_date: "2002-12-06"},
]
Answer the question
In order to leave comments, you need to log in
RTFM
const arr = await getStartEndDateInTradePage.findAll(
{
attributes: ['open_date', 'close_date'],
where: {
close_date: {
[Op.ne]: '-'
}
}
}
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question