Open BLACKJACKDEVELOPER opened 1 year ago
hey so am new here so can u assign me this issue here
async get(req,res) { try { const { query:{ room } } = req const data = await msgs.aggregate([ { $lookup: { from: "users", localField: "user_id", foreignField: "_id", as: "UserDetail" } } ]); console.log(data) return res.json({ data, pass:true }) }catch(e) { console.log(e) return res.json({ pass:false, msg:e.message }) } } hey i think there is a typo error in your code assuming if u want to match the id which I think is ObjectId so just have to change "id" to "_id"
Here is my code that attempt to use $lookup.I think it's correct but "UserDetail" give me a [] to all data