Spring Mongo how to do query across different datatbase

27 Views Asked by At

I need to migrate from single database to two database,

and my project have a lookup aggregation like

 LookupOperation lookupOperation = LookupOperation.newLookup()
            .from("race")
            .localField("carId")
            .foreignField("carId")
            .as("result");


List<AggResult> outputs= racemongoTemplate.aggregate(aggregation, "user",
                AggResult.class).getMappedResults();

across two collection"Race" and "User" in same database now since two collection is separated, how can i do such a query in two different database, say "Race" in database 1 , and "User" in database2

thanks

0

There are 0 best solutions below