In the mongodb 4.0
Can I lookup query data after map function? I used map function for convert string to object.
db.app_auditLogs.aggregate()
.match(match)
.lookup({
from: "users",
localField: "createdBy",
foreignField: "_id",
as: "userDoc"
})
.unwind({ path: '$userDoc', preserveNullAndEmptyArrays: true })
.addFields({ userName: '$userDoc.profile.fullName' })
.map(it => {
if (it.data) {
it.data = JSON.parse(it.data)
if (_.includes(['Invoice' ], it.data.tranType)||_.includes(['Invoice'], it.data.journalType)) {
return it
}
}
})
Example:
db.app_auditLogs.aggregate()
.match(match)
.lookup()
.unwind()
.map()
.match()?
.lookup()?
Please recommend me,Thanks before.