You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered: