简体   繁体   中英

MongoDB - How to query details from multiple collections in a single query

I have a scenario where i have to fetch data from multiple/different collections and compare the documents then return the result. Currently i'm doing it from application side using multiple sequential queries to fetch data those collections, but this is slower.

I want to do it in a single query. It it possible? Basically i'm looking for a sql's stored procedure kind of solution in MongoDB. I'm using Morphia java.

Thanks for you help.

Joins are not currently supported in MongoDB. However, 3.2 will add the $lookup aggregation pipeline stage which may or may not meet your needs. In general, schema designs in MongoDB should avoid the need for doing joins. That being said, sometimes you need them and $lookup might solve that problem for you. Otherwise, you should any joining in your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM