我从mongodb获得数据,如何更改每个对象的banner_image值。 我需要完整的图像路径 我正在使用猫鼬5.2.16
[ { banner_status: '1',
banner_title: 'this is banner title 1',
banner_url_link: 'this-is-banner-title-1',
banner_image: '1b98ef928319dcd71542611234210.png',
banner_desc: 'this is banner desc 1',
banner_offer_type: '1' },
{ banner_status: '1',
banner_title: 'this is banner title 2',
banner_url_link: 'this-is-banner-title-2',
banner_image: '596bf45a293ed6411542611244223.png',
banner_desc: 'this is banner desc 2',
banner_offer_type: '1' },
{ banner_status: '1',
banner_title: 'this is banner title 3',
banner_url_link: 'this-is-banner-title-3',
banner_image: '95e34d34f27b9a161542611253871.png',
banner_desc: 'this is banner desc 3',
banner_offer_type: '1' } ]
这是我的代码。
router.get('/get-list-banner', async (req, res) => {
try {
const offerBanner = await restListbanner.find({banner_status: '1'}, { _id: 0, __v: 0 });
if(!offerBanner) return res.status(200).json({ success: false, message: "No Banners Found" });
res.status(200).json({ success: true, message: "Restaurants Offer Banners", bannerData: offerBanner });
} catch (error) {
res.status(400).json({ success: false, message: error });
}
});