diff options
| author | Bobby <[email protected]> | 2022-04-25 14:52:09 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-04-25 14:52:09 -0400 |
| commit | fc6c6db3dd3864049a1be73953c06cd244138c33 (patch) | |
| tree | 9ffbf604355ded8681c38634670816e8093772b4 /interface/controllers/citizens.controller.js | |
| parent | c9d6c587a56e5e7420f48579894831cdb05756d9 (diff) | |
| download | Welfare-Schemes-DMQL-fc6c6db3dd3864049a1be73953c06cd244138c33.tar.xz Welfare-Schemes-DMQL-fc6c6db3dd3864049a1be73953c06cd244138c33.zip | |
basic api using postgres and sequelize
Diffstat (limited to 'interface/controllers/citizens.controller.js')
| -rw-r--r-- | interface/controllers/citizens.controller.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/interface/controllers/citizens.controller.js b/interface/controllers/citizens.controller.js new file mode 100644 index 0000000..fef549d --- /dev/null +++ b/interface/controllers/citizens.controller.js @@ -0,0 +1,17 @@ +const db = require("../models"); +const citizens = db.citizens; +const op = db.Sequelize.Op; + +// Retrieve all citizens from the database. Limit the number of citizens returned to 10. +exports.findXCitizens = (req, res) => { + const limit = 10; + citizens.findAll({ + limit: limit + }).then(citizens => { + res.send(citizens); + }).catch(err => { + res.status(500).send({ + message: err.message || "Some error occurred while retrieving citizens." + }); + }); +} |
