Skip to content

Commit

Permalink
Sort items returned by admin endpoints based on the update time
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshGajabi committed Dec 15, 2023
1 parent a8d61dc commit a655e22
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { getTransporter } = require('../utils/otp');

module.exports.getAllLostItems = async (req, res, next) => {
try {
const lostItems = await LostItem.find({});
const lostItems = await LostItem.find({}).sort({ updatedAt: -1 });
res.json({ lostItems });
} catch (err) {
console.error("Error fetching all lostItems:", err);
Expand All @@ -14,7 +14,7 @@ module.exports.getAllLostItems = async (req, res, next) => {

module.exports.getAllFoundItems = async (req, res, next) => {
try {
const foundItems = await FoundItem.find({});
const foundItems = await FoundItem.find({}).sort({ updatedAt: -1 });
res.json({ foundItems });
} catch (err) {
console.error("Error fetching all foundItems:", err);
Expand All @@ -24,7 +24,7 @@ module.exports.getAllFoundItems = async (req, res, next) => {

module.exports.getAllPotentialMatches = async (req, res, next) => {
try {
const potentialMatches = await PotentialMatch.find({});
const potentialMatches = await PotentialMatch.find({}).sort({ updatedAt: -1 });
res.json({ potentialMatches });
} catch (err) {
console.error("Error fetching all potentialMatches:", err);
Expand Down

0 comments on commit a655e22

Please sign in to comment.