Db.getcollection ('test1_table').aggregate([# left table' test1_table' condition filter {$match: {" cityName ", "chongqing", "districtName" : "jiulongpo district", "month" : {$gte: 202005, $lte: 202008}}} {# $lookup table join operations: { Let :{"cityId":"$cityId","month":"$cityId"}, "$month" :"$cityId"}, "$month" :"$month"}, "$month" :"$month"}, Let :{"cityId":"$cityId","month":"$cityId"} let:{"cityId":"$cityId","month":"$month"} $$cityId, corresponding field value $$$month right table match: {$expr: {$and: [{$eq: [$" cityId ", "$$" cityId]}, {$eq: [" $month", "$$month"]}]}}}], # connection right under the table in the left table test1_table test2_table data structure of the field name as: "data"}}, # right table filter {$match: {" data. Type ":" 1 ", "data. Num" : {10} : $gte: 0, $lte, "data. IsDeleted" : false}}, # split array, An empty array is also split a {$unwind: {path: "$data," preserveNullAndEmptyArrays: true}}, {10} $limit: # paging parameters, {$skip: 0},])Copy the code

Blog.csdn.net/ab52262879/…