From 6aa911609fc58e5d992631b5a2d9cc3e036740cf Mon Sep 17 00:00:00 2001 From: surya Date: Sat, 21 Aug 2021 17:25:27 +0530 Subject: [PATCH] Surya:20-08-2021 GD changes --- app/controllers/master.controller.js | 14 +++++++++----- app/models/Itemsmaster.js | 9 +++++++++ server.js | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/controllers/master.controller.js b/app/controllers/master.controller.js index 74e09e5..1a68909 100644 --- a/app/controllers/master.controller.js +++ b/app/controllers/master.controller.js @@ -13,10 +13,11 @@ const { logMsg } = require('../services/logger.js'); // Retrieve all statements from the database. exports.StatementsList = async (req, res) => { - await Statementsmaster.findAll({where : { is_active : 1 } }) + await Statementsmaster.findAll() .then(data => { res.send({'status':200,'message':"success",'data':data}); - logMsg.info("Success :"(data)); + logMsg.info("Success "); + }) .catch(err => { res.send({'status':404, @@ -89,7 +90,8 @@ exports.Deletestatement = async (req, res) => { // Retrieve all Sectionsmaster from the database. exports.SectionList = (req, res) => { - Sectionsmaster.findAll({where : { is_active : 1 } }) + //Sectionsmaster.findAll() + sequelize.query("SELECT sectionsmaster.id,sectionsmaster.statement as statement_id,statementsmaster.statement,sectionsmaster.section,sectionsmaster.is_active,sectionsmaster.createdby,sectionsmaster.createdon,sectionsmaster.updatedby,sectionsmaster.updatedon FROM sectionsmaster INNER JOIN statementsmaster ON sectionsmaster.statement=statementsmaster.id;") .then(data => { res.send({'status':200,'message':"success",'data':data}); logMsg.info("Success :"(data)); @@ -166,7 +168,8 @@ exports.Deletesection = (req, res) => { // Retrieve all Subsectionsmaster from the database. exports.SubsectionList = (req, res) => { - Subsectionsmaster.findAll({where : { is_active : 1 } }) + //Subsectionsmaster.findAll() + sequelize.query("SELECT subsectionsmaster.id,subsectionsmaster.section as section_id,sectionsmaster.section,subsectionsmaster.subsection,subsectionsmaster.itemtext,subsectionsmaster.is_active,subsectionsmaster.createdby,subsectionsmaster.createdon,subsectionsmaster.updatedby,subsectionsmaster.updatedon FROM subsectionsmaster INNER JOIN sectionsmaster ON subsectionsmaster.section=sectionsmaster.id") .then(data => { res.send({'status':200,'message':"success",'data':data}); logMsg.info("Success :"(data)); @@ -242,7 +245,8 @@ exports.Deletesubsection = (req, res) => { // Retrieve all itemsmaster from the database. exports.ItemList = (req, res) => { - Itemsmaster.findAll({where : { is_active : 1 } }) + //Itemsmaster.findAll() + sequelize.query("SELECT itemsmaster.id,itemsmaster.statement as statement_id,statementsmaster.statement,itemsmaster.section as section_id,sectionsmaster.section,itemsmaster.subsection as subsection_id,subsectionsmaster.subsection ,itemsmaster.itemtext,itemsmaster.is_active,itemsmaster.createdby,itemsmaster.createdon,itemsmaster.updatedby,itemsmaster.updatedon FROM itemsmaster JOIN statementsmaster ON itemsmaster.statement=statementsmaster.id JOIN sectionsmaster ON itemsmaster.section= sectionsmaster.id JOIN subsectionsmaster ON itemsmaster.subsection= subsectionsmaster.id") .then(data => { res.send({'status':200,'message':"success",'data':data}); logMsg.info("Success :"(data)); diff --git a/app/models/Itemsmaster.js b/app/models/Itemsmaster.js index 8a51d0a..c8c9eb5 100644 --- a/app/models/Itemsmaster.js +++ b/app/models/Itemsmaster.js @@ -11,6 +11,15 @@ module.exports = (sequelize, DataTypes) => { //static associate({ Model_name }) { //this.hasMany(Model_name, { foreignKey: 'child_table_prim_key', as: 'child_tbl_name' }) //} + static associate({ Statementsmaster }) { + this.belongsTo(Statementsmaster, { foreignKey: 'id', as: 'statementsmasterData' }) + } + static associate({ Subsectionsmaster }) { + this.hasMany(Subsectionsmaster, { foreignKey: 'section', as: 'subsectionsmasterData' }) + } + static associate({ Sectionsmaster }) { + this.hasMany(Sectionsmaster, { foreignKey: 'statement', as: 'sectionsmasterData' }) + } } diff --git a/server.js b/server.js index 24db99b..cbbc831 100644 --- a/server.js +++ b/server.js @@ -1,7 +1,7 @@ require('dotenv').config(); const express = require('express') const app = express() - +//it is used to clear cache app.use(function(req, res, next) { res.set("Cache-Control", "no-cache, no-store, must-revalidate, max-age=0") res.set("Pragma", "no-cache")