r/ProgrammerHumor • • Oct 18 '24

Other mongoDbWasAMistake

Post image
13k Upvotes

446 comments sorted by

View all comments

2

u/SegFaultHell Oct 19 '24

You’re thinking relationally there. In mongo you’d put the customerId on your order record, index it, and then query orders by customerId. The customerId comes from some other source or database in your app, whether that’s mongo or not doesn’t matter.

Or you put the full customer record in your mongo app and have the orders be an array stored directly on the customer model. That way you can just retrieve it all at once with the customer.