第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

僅當(dāng)變量條件不是未定義時(shí)才過(guò)濾

僅當(dāng)變量條件不是未定義時(shí)才過(guò)濾

慕運(yùn)維8079593 2021-06-09 08:24:40
這是我的路由器:reportRoutes.route('/:id').get(async (req, res) => {    try{        let id = req.params.id        console.log(req.query)        let team = req.query.team        let league_acronym = req.query.league        console.log('team',team)        let regex = new RegExp( id, 'i')        const report = await Report.find({ title: regex })            .populate({path: 'like'})            .populate({                path: 'player',                populate: [{ path: 'team' },                {                    path: 'team',                    populate: {                        path: 'league'                    }                }            ]            })            if(league_acronym) {                newReport = report.filter((v,i) => {                    return v.player.team.league.acronym === league_acronym  && v.player.team.team_name === team                })                res.json(newReport)            } else{                res.json(report)            }    }  catch (e) {        res.status(500).send()    }})我正在嘗試設(shè)置一個(gè)通過(guò)報(bào)告并返回 newReport 的過(guò)濾器。它將過(guò)濾的條件基于查詢(xún)字符串參數(shù)。因?yàn)椴樵?xún)字符串參數(shù)并不總是存在,所以我需要一種方法來(lái)過(guò)濾條件,僅當(dāng)條件存在時(shí)。想法?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 167 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)