You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

50 lines
1.2 KiB

const asyncHandler = require("../Middleware/async");
const sequelize = require('sequelize')
const DataModel = require("../Model/TD_DATA");
exports.getAllSubscriptions = asyncHandler(async (req, res, next) => {
DataModel.findAll({
where: {
DATA_TYPE: "POS_PLAN"
},
order: [
[sequelize.literal('CAST([FIELD_2] AS FLOAT)'), 'ASC'] // Sort by FIELD_2(Price) as integer
]
}).then((data) => {
return res.status(200).send(JSON.stringify(
{
success: true,
data
}
));
});
})
exports.getSubscriptionByID = asyncHandler(async (req, res, next) => {
const { id } = req.query;
console.log("PLAN ID :", id)
DataModel.findOne({
where: {
ID: id,
DATA_TYPE: "POS_PLAN"
},
order: [
[sequelize.literal('CAST([FIELD_2] AS FLOAT)'), 'ASC'] // Sort by FIELD_2(Price) as integer
]
}).then((data) => {
console.log("GET SUBSCRIPTION BY ID", data.DATA_CODE)
return res.status(200).send(JSON.stringify(
{
success: true,
data
}
));
});
})