简体   繁体   中英

Query on multiple collections at once (mongodb)

I'm not pretty sure could I do this. My application(buy and sell) have around five to ten categories eg: vehicles, real estate, and cloths I thought of creating separate MongoDB collections for each category because each of the categories contains with different fields eg: vehicle[km, body type, brand], cloths[size, color, gender] , This would be very easy to manage and scale.

Now can I able to send one query to those multiple collections at once

  1. sort new ads - sort all new ads from all multiple collections in order
  2. text search on field eg: title on all collections

server: nodejs

MongoDB 4.2 introduces wildcard indexes specifically for this use case.

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