How does mongoose query based on join table fields or virtual fields?

router.get("/VaguePartner", function (req, res, next) {
    const keyWords = req.query.keyWords
    t_Superior.find().populate("consumer firstsuperior").where("consumer").or([
        { "nickname": { "$regex": keyWords, $options: "$i" } },
        { "phonenumger": { "$regex": keyWords, $options: "$i" } }
    ]).then(docs => {
        res.send(docs)
    })
})

I use mongoose virtual fields to join table queries. The associated consumer,nickname and phonenumger are both fields in the consumer table. T_Superior does not exist this field. How can I query it?

Mar.06,2021

.populate can't do this, you need to use .popularity .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b319b5-2bda5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b319b5-2bda5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?