aggregate

    Node.js Mongodb aggregate lookup

    router.get('/answers/like', authMiddleware, async (req, res) => { try { const user = res.locals.user; let { page } = req.query; page = (page - 1 || 0) < 0 ? 0 : page - 1 || 0; const answerCount = await AnswerCard.find({ userId: user.userId }); const myAnswerInfo = await AnswerCard.aggregate([ { $match: { userId: { $eq: user.userId } } }, { $project: { _id: { $toString: '$_id' }, questionId: 1, c..