0

Does the action of getting data from mongo a blocking operation in node (if done incorrectly ?). What is the best way to make a query and also what should i avoid.I am using mongoosejs.

1 Answer 1

2

Andrei, Node makes synchronous & blocking stuff really hard to do, so don't worry so much. I advise you read the official documentation from Mongoose and then take a look at the Nodepad application developed by Alex Young.

The tutorials for that application can be found here: http://dailyjs.com/tags.html#nodepad

Also in general, Mongoose & Node code usually look like this:

database.query(conditions, function(error, data) {
  if (error) { throw error; return; }
  // do stuff with your data here
});

Other useful resources:

Is there any good MongooseDB Tutorial / example website?
Video presentations on Node.js & MongoDB from 10gen's official website: http://www.10gen.com/presentations#programming_lang__javascript_nodejs
http://nodenerd.net/post/4926637100/quick-hit-mongoose-js
http://blog.mongodb.org/post/6587009156/cloudfoundry-mongodb-and-nodejs

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.