简体   繁体   中英

MongoDB query results aggregation

I need to aggregate results of multiple searches together.

Currently, we do multiple lookups. For example, first - find user, then using retrieved userid find work order, then for each product ID in the order, lookup full product information.

Can this be aggregated into a single query, somehow?

Depends allot on how you handle your schema, so my answer could vary depending on what your specific needs are. however I did post a way on a work around to a similar situation (in a example of 3 schemas) you can find it here .

also it depends on if you have object id references or not, if its all stored directly then it could be a single aggregation query.

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