MongoDB多文档查询
1 db.getCollection('transactionCompensation').find( 2 { 3 "$and":[ 4 { 5 "status":{ 6 "$eq":0 7 } 8 }, 9 { 10 "count":{ 11 "$lt":5 12 } 13 } 14 ] 15 } 16 ); 17 18 { 19 "aggregate":"order", 20 "pipeline":[ 21 { 22 "$lookup":{ 23 "from":"order", 24 "localField":"_id", 25 "foreignField":"_id", 26 "as":"order" 27 } 28 }, 29 { 30 "$lookup":{ 31 "from":"businessOrderHandling", 32 "localField":"_id", 33 "foreignField":"orderId", 34 "as":"businessOrderHandling" 35 } 36 }, 37 { 38 "$lookup":{ 39 "from":"buyerInformationPreparation", 40 "localField":"_id", 41 "foreignField":"orderId", 42 "as":"buyerInformationPreparation" 43 } 44 }, 45 { 46 "$lookup":{ 47 "from":"mortgageAndWarrantOrder", 48 "localField":"_id", 49 "foreignField":"orderId", 50 "as":"mortgageAndWarrantOrder" 51 } 52 }, 53 { 54 "$lookup":{ 55 "from":"slOrder", 56 "localField":"_id", 57 "foreignField":"orderId", 58 "as":"slOrder" 59 } 60 }, 61 { 62 "$lookup":{ 63 "from":"activateTask", 64 "localField":"_id", 65 "foreignField":"orderId", 66 "as":"activateTask" 67 } 68 }, 69 { 70 "$match":{ 71 "activateTask.statementHandling":Object{...}, 72 "$and":[ 73 { 74 "$or":[ 75 { 76 "businessManCityId":523353 77 }, 78 { 79 "creatorCityId":523353 80 } 81 ] 82 } 83 ] 84 } 85 } 86 ] 87 }
1 db.businessOrderHandling.find({ 2 "redemptionHouseHandlingPol.rhHandlingNode": { 3 "$elemMatch": { 4 "processNode": 'rFloorFinanceAudit', 5 "isInAliyun": 0 6 } 7 } 8 }); 9 10 db.businessOrderHandling.find({ 11 "redemptionHouseHandlingPol.rhHandlingNode": { 12 "$elemMatch": { 13 "processNode": { 14 "$in": ['rFloorFinanceAudit', 'rFloorLoan'] 15 }, 16 "isInAliyun": 0 17 } 18 } 19 });
{ "aggregate":"order", "pipeline":[ { "$lookup":{ "from":"order", "localField":"_id", "foreignField":"_id", "as":"order" } }, { "$lookup":{ "from":"mortgageAndWarrantOrder", "localField":"_id", "foreignField":"orderId", "as":"mortgageAndWarrantOrder" } }, { "$lookup":{ "from":"buyerInformationPreparation", "localField":"_id", "foreignField":"orderId", "as":"buyerInformationPreparation" } }, { "$lookup":{ "from":"slOrder", "localField":"_id", "foreignField":"orderId", "as":"slOrder" } }, { "$lookup":{ "from":"businessOrderHandling", "localField":"_id", "foreignField":"orderId", "as":"businessOrderHandling" } }, { "$lookup":{ "from":"businessOrderAuditing", "localField":"_id", "foreignField":"orderId", "as":"businessOrderAuditing" } }, { "$lookup":{ "from":"activateTask", "localField":"_id", "foreignField":"orderId", "as":"activateTask" } }, { "$match":{ "activateTask.slHandling":{ "$exists":true }, "slOrder.handlerName":{ "$exists":true }, "$and":[ { }, { } ] } }, { "$project":{ "_id":"$order._id" } } ] }
[ { "$lookup":{ "from":"order", "localField":"orderId", "foreignField":"_id", "as":"order" } }, { "$match":{ "order.businessSource.organizationStoreId":"01005201706290948060003000000" } }, { "$group":{ "_id":"$feeUseDetail", "count":{ "$sum":1 }, "totalLoanCount":{ "$sum":"$rpFee" } } }, { "$project":{ "groupById":"$_id", "count":1, "totalLoanCount":1 } }, { "$sort":{ "count":-1 } } ]
{ "aggregate":"order", "pipeline":[ { "$lookup":{ "from":"order", "localField":"_id", "foreignField":"_id", "as":"order" } }, { "$lookup":{ "from":"mortgageAndWarrantOrder", "localField":"_id", "foreignField":"orderId", "as":"mortgageAndWarrantOrder" } }, { "$lookup":{ "from":"buyerInformationPreparation", "localField":"_id", "foreignField":"orderId", "as":"buyerInformationPreparation" } }, { "$lookup":{ "from":"slOrder", "localField":"_id", "foreignField":"orderId", "as":"slOrder" } }, { "$lookup":{ "from":"businessOrderHandling", "localField":"_id", "foreignField":"orderId", "as":"businessOrderHandling" } }, { "$lookup":{ "from":"businessOrderAuditing", "localField":"_id", "foreignField":"orderId", "as":"businessOrderAuditing" } }, { "$lookup":{ "from":"activateTask", "localField":"_id", "foreignField":"orderId", "as":"activateTask" } }, { "$match":{ "applyForDate":{ "$gte":{ "$date":"2017-11-08T16:00:00.000Z" }, "$lt":{ "$date":"2017-12-01T16:00:00.000Z" } }, "_id":{ "$regex":"3ABC-201711220002" }, "businessManId":192493, "businessManDeptId":23968115, "businessCityId":618012, "buyers.name":{ "$regex":"阿斯蒂芬" }, "buyers.cellphone":"18878788585", "salers.name":{ "$regex":"范德萨" }, "salers.cellphone":"18878788585", "slOrder._id":"X_ABC-201711220002", "slOrder.slCategory":1, "activateTask.slHandling":"controlCard", "slOrder.handlerName":{ "$exists":true }, "$and":[ { "$or":[ { "buyers.certificateNumber":"234243199202021515" }, { "salers.certificateNumber":"234243199202021515" } ] }, { "$or":[ { "buyers.certificateType":1 }, { "salers.certificateType":1 } ] } ] } }, { "$sort":{ "applyForDate":-1 } }, { "$skip":0 }, { "$limit":10 } ] }
^_^