Type-safe MongoDB aggregations.
Now available as @pipesafe/core on NPM.
db.orders.aggregate([ { $lookup: { from: "users", localField: "userId" // missing foreignField and as }}, { $match: { total: { $gt: "100" } }}, { $set: { withTax: { $multiply: ["$totl", 1.2] }, fullName: { $concat: [ "$firstName", 123 ]} }}, { $project: { withTax: 1, fullName: 1 }} ])
db.orders.aggregate<Order>() .lookup({ from: "users", localField: "userId", foreignField: "_id", as: "user" }) .match({ total: { $gt: "100"100 } }) .set({ withTax: { $multiply: ["$totl""$total", 1.2] }, fullName: { $concat: [ "$firstName", 123" ", "$lastName" ]} }) .project({ withTax: 1, fullName: 1 })