Mongodb order schema Design issues

see a shopping item in github. All user orders create a schema1 to store all user orders. User personal information creates schema2,schema2. In addition to basic information, there is a personal order: [] to store personal orders.

there is a question. Since all user orders are saved in schema1, users can check whether their own orders can be directly checked in schema1. If the amount of data is large, create an index in the order personal userID, so that users should quickly check their own orders, so it is not necessary to build oredr: [].
in addition, when querying according to the order number, mongodb generates a unique _ id, when creating the data. Whether you can use this _ id to do some processing as the order number.

Mar.30,2021

  • maybe this project has a so-called historical legacy , starting with schema2.order . Then there is schema1 .
  • is also the technical boss who wants to see if the Arrey subcollection paging query of mongo is useful.
  • Space for time. The database breaks TB easily.

the above is pure nonsense.

another: _ id can be directly used as an order id . The _ id generation algorithm of mongo is a distributed id generation algorithm. Timestamp + machine code + process Id+ random number

Menu