diff options
| author | Bobby <[email protected]> | 2022-05-03 22:04:04 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-05-03 22:04:04 -0400 |
| commit | f1b9662122abed09ccf74b2eda034e7a45730e60 (patch) | |
| tree | 2e34ce476542d17871791d19fb45fd6a20d61bfa /interface/controllers/citizens.controller.js | |
| parent | 00826988bf4d1fba76c0a65fa850639844ef61a4 (diff) | |
| download | Welfare-Schemes-DMQL-f1b9662122abed09ccf74b2eda034e7a45730e60.tar.xz Welfare-Schemes-DMQL-f1b9662122abed09ccf74b2eda034e7a45730e60.zip | |
citizens pagination
Diffstat (limited to 'interface/controllers/citizens.controller.js')
| -rw-r--r-- | interface/controllers/citizens.controller.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/interface/controllers/citizens.controller.js b/interface/controllers/citizens.controller.js index 0e45a13..3bec103 100644 --- a/interface/controllers/citizens.controller.js +++ b/interface/controllers/citizens.controller.js @@ -5,23 +5,26 @@ const { sequelize } = require("../models"); // Retrieve all citizens from the database. Limit the number of citizens returned to 10. -exports.findXCitizens = () => { - query = `select c.citizen_id, c.first_name, c.last_name, c.address, c.mobile_num, c.dob, c.gender, c.marital_status, c.village_id, v.village_name +exports.findXCitizens = (limit, offset) => { + const query = `select c.citizen_id, c.first_name, c.last_name, c.address, c.mobile_num, c.dob, c.gender, c.marital_status, c.village_id, v.village_name from citizens c join village_master v on c.village_id = v.village_id - order by citizen_id limit 10;`; + order by citizen_id limit ${limit} offset ${offset};`; return sequelize.query(query, { type: QueryTypes.SELECT }) }; +exports.getCountOfCitizens = () => { + const query = `select count(*) as count from citizens;`; + return sequelize.query(query, { type: QueryTypes.SELECT }) +} -exports.deleteCitizenbyId = (citizen_id) =>{ +exports.deleteCitizenbyId = (citizen_id) =>{ return citizens.destroy({ where: { citizen_id } }) - }; exports.editCitizen = (citizen_id, address, mobile_num, dob, marital_status) => { |
