Reputation: 8582
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.
Upvotes: 0
Views: 799
Reputation: 63663
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
Upvotes: 2