I am relatively new to Node.js and working on a project with MongoDB as database. Some of the MongoDB queries are expensive. For example, I have a collection with millions of records and based on the search criteria the find query can take 1-2 seconds.
Does the call to MongoDB (using Mongoose driver) block Node.js from processing other requests until MongoDB returns results?
Also, are there any tools to identify potential lines of code that are of a blocking nature?
Thank you.
@user949300 provided correct answer.
In general, if they have a callback in the function signature they ar non-blocking. e.g. MongoClient.connect('mongodb://127.0.0.1:27017/test', function(err, db) has a callback function(err, db) and is non- blocking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With