MongoDB query performance with Promise
The find()
approach should be faster for numerous reasons. First, it sends one query as opposed to one for every order, so fewer round trips to the database. A much less significant performance impact also comes from the fact that you're creating a new promise for every findOne()
call.
Also, I don't think GetOrders()
as written actually works. I think you meant to use Order.findById(orderId)
, or Order.findOne({ _id: orderId })