From 2870a0995b097989d614f1fe65b96992a5b53b52 Mon Sep 17 00:00:00 2001 From: Mr Swift Date: Tue, 6 Aug 2024 19:07:47 +0330 Subject: [PATCH] Fix populate --- server/controllers/GPS.InstalledDevice.js | 2 +- server/controllers/GPS.Request.js | 4 ++-- server/controllers/GPS.Withdraw.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/controllers/GPS.InstalledDevice.js b/server/controllers/GPS.InstalledDevice.js index b718f75..53f8391 100644 --- a/server/controllers/GPS.InstalledDevice.js +++ b/server/controllers/GPS.InstalledDevice.js @@ -48,7 +48,7 @@ module.exports.getAllForUser = async(req, res)=>{ } module.exports.getAllForAdmin = async(req, res)=>{ - const data = await InstalledDevice.find({}).sort({status: 1}).populate('deviceId userId') + const data = await InstalledDevice.find({}).sort({status: 1}).populate('deviceId').populate('userId', 'shopName shopNumber shopAddress birthDate score first_name last_name profilePic') res.status(200).json(data) } diff --git a/server/controllers/GPS.Request.js b/server/controllers/GPS.Request.js index 74b23e5..8761e40 100644 --- a/server/controllers/GPS.Request.js +++ b/server/controllers/GPS.Request.js @@ -35,7 +35,7 @@ module.exports.gpsRequest = [ module.exports.getAllRequest = [ async (req, res) => { - const data = await RequestGPS.find({}).sort({ status: 1 }).populate('userId') + const data = await RequestGPS.find({}).sort({ status: 1 }).populate('userId', 'shopName shopNumber shopAddress birthDate score first_name last_name profilePic') res.status(200).json(data) } ] @@ -46,7 +46,7 @@ module.exports.getOneRequest = [ ], checkValidations(validationResult), async (req, res) => { - const data = await RequestGPS.findById(req.params.id).populate('userId') + const data = await RequestGPS.findById(req.params.id).populate('userId', 'shopName shopNumber shopAddress birthDate score first_name last_name profilePic') res.status(200).json(data) } ] diff --git a/server/controllers/GPS.Withdraw.js b/server/controllers/GPS.Withdraw.js index cc99544..b94c0ec 100644 --- a/server/controllers/GPS.Withdraw.js +++ b/server/controllers/GPS.Withdraw.js @@ -38,7 +38,7 @@ module.exports.getAllForUser = async (req, res) => { module.exports.getAllForAdmin = async (req, res) => { - const requests = await Withdraw.find().sort({ status: 1 }).populate('userId') + const requests = await Withdraw.find().sort({ status: 1 }).populate('userId', 'shopName shopNumber shopAddress birthDate score first_name last_name profilePic') res.status(201).json(requests) }