直到最后一个版本的spring我已经看到很多堆栈溢流问题,这表明在spring-data-mongodb中没有对此操作的支持在新的spring-data-mongodb 1.10.0中是否支持此操作
db.orders.aggregate([
{
$lookup:
{
from: "inventory",
localField: "item",
foreignField: "sku",
as: "inventory_docs"
}
}
])
答案 0 :(得分:3)
自1.9版以来一直有查找支持。
LookupOperation lookupOperation = LookupOperation.newLookup().
from("inventory").
localField("item").
foreignField("sku").
as("inventory_docs");
Aggregation aggregation = Aggregation.newAggregation(lookupOperation);
List<BasicDBObject> results = mongoOperations.aggregate(aggregation, "orders", BasicDBObject.class).getMappedResults();