3

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.

1
  • 1
    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. Commented Jul 23, 2014 at 6:37

1 Answer 1

4

@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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.