0

I have the following MongoDb query:

db.table.aggregate([
{
    $lookup:
    {
        from: "secondTable",
        localField: "_id",
        foreignField: "_id",
        as: "secondTableDto"
    }
},
{
    $unwind: "$secondTableDto"
},
{
    $lookup:
    {
        from: "accounts",
        pipeline: [],
        as: "accountDto"
    }
},
...........

The query is working and now I'm trying to parse it to Spring Data Mongo but I can't find how to do the last lookup with just the pipeline.

Does Spring support it? I've read on the website this feature was released on Mongo 3.6

Thank you

  • [spring data Lookup operation javadoc](https://docs.spring.io/spring-data/data-mongo/docs/current/api/org/springframework/data/mongodb/core/aggregation/LookupOperation.html) or this custom solution https://stackoverflow.com/a/36145440/3224238 – Paizo Jun 26 '18 at 08:22
  • Hi @Paizo I've tried the second one and I get: unknown argument to $lookup: pipeline", "code" : 4571.. The Lookup Operation requires localField and foreignField which I don't have on this case – Aníbal Catheringer Jun 26 '18 at 09:19
  • 2
    Indeed pipelines are not supported, so you have you convert your JSON into `Document` as in [this example](https://stackoverflow.com/a/46357760/267197) and then wrap it in `AggregationOperation` as in [this example](https://stackoverflow.com/a/51199990/267197). If you wish I can share my solution but it is simply a combination of above. – dma_k Apr 09 '20 at 12:45

0 Answers0