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 } )); }); })