Mongodb $lookup Not working with _id

后端 未结 7 2263
猫巷女王i
猫巷女王i 2020-12-31 09:43

wend try with this query, return the lookup is empty

db.getCollection(\'tests\').aggregate([
    {$match: {typet:\'Req\'}},
    {$project: {incharge:1}},
            


        
7条回答
  •  灰色年华
    2020-12-31 10:29

    try changing type of incharge which is string to ObjectId in aggregate function like this

    { 
        $project : {
            incharge : {
                $toObjectId : "$incharge"
            }
        }
    }
    

提交回复
热议问题