I have two collection called "Order" and "Production Order ". I have record limit for 40 on each page . So I need to display total 40 records from both .I have number of question as below mention .
1) Can we get records for two collection from one query ?. 2) If i will use two query its really hard to display because in case of "Orders " will come 30 and "Production Order "will come 10 and if give limit of 20 for each collection 10 remaining will not display from "Orders "
possible ways i can think now for your requirement will be
1) Use relationShip ( 1To1
, 1ToMany
, ManyToMany
) and then fetch relative data using .populate()
function of mongoose to get desired data
2) Or you can use data replication (inCase you done want relationship in Database)
"order": {
"_id": "313424535435", // you can add other relevant data according to you need
"production_order": {
"_id": "127342684783" // only add that data which is necessary
}
}
and Vice-versa
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.