时间:2021-07-01 10:21:17 帮助过:1人阅读
leftT集合:
comments集合:
现在我们要用aggregation实现inner join
db.comments.aggregate([{ $lookup: { from:"leftT", localField:"timestamp", foreignField:"timestamp", as: "timestampCol" }}, {$unwind: "$timestampCol"}, {$project: {"ratingEQ": {"$eq": ["$rating", "$timestampCol.rating"]}, "timestamp" : 1, "rating" : 1, "timestampCol.timestamp": 1}}, {$match: {"ratingEQ":true}} ])
是不是很神奇?
步骤解析:
MongoDB 学习笔记之 Aggregation Pipeline实战实现inner join
标签:blog line class ora text http foreign div bsp