top | item 3176846

Nodejs and MongoDB, A Beginner's Approach

59 points| ksetyadi | 14 years ago |blog.ksetyadi.com | reply

33 comments

order
[+] qF|14 years ago|reply
This guide really shows what I think is a big problem with a lot of Node guides, they don't go beyond the first 5 minutes.

There are a ton of guides on how to set up a webserver in 20 lines, but hardly any on how to (properly) handle a lot of async callbacks and requests etc.

[+] ksetyadi|14 years ago|reply
It's hard to cover many aspects of it when we talked about getting our feet wet. I try to include as few terms as possible that potentially confused people to start coding Nodejs-MongoDB. It's probably a big problem when you try to get your feet wet on the first day you learn about swimming just by jumping all over the pool. But then, hopefully, we learn.

Thanks for your opinion :)

[+] mcantelon|14 years ago|reply
Going into how to handle a lot of async callbacks/requests would be entirely different subject matter, would it not? The blog post is titled "Nodejs and MongoDB, A Beginner’s Approach" and that's the subject matter it tackles.
[+] Finbarr|14 years ago|reply
Agree with this. Was disappointed the guide didn't delve into asynchronous even at a basic level. This is what makes nodejs and mongodb worth using and I don't think the concepts are overly difficult to grasp.
[+] Srirangan|14 years ago|reply
To be honest, a good attempt by the author but I wouldn't recommend this to a beginner. Why? I don't recommend the use of the native driver - you end up with needlessly complex code.

I don't want to criticize the authors work. He's done a pretty good and thorough job. Hopefully I'll pen down an easier guide later tonight.

[+] mcantelon|14 years ago|reply
Yeah, I'd say many folks will probably end up wanting to use something like Mongoose to abstract the nitty-gritty details of Node/MongoDB interaction, but knowing how to use the underlying library (and node-mongodb-native is the most popular of them by far) is healthy for beginners.
[+] ksetyadi|14 years ago|reply
It's always nice to have another point of view within a subject. Would like to know more.
[+] stottc|14 years ago|reply
There's something incredibly natural about node & mongo together.
[+] frou_dh|14 years ago|reply
They're both Web Scale
[+] dextorious|14 years ago|reply
Actually it's more like: hey, let's take two tools that ought to be used with utmost caution by people who know what they're doing and why they need them, and present them as the best thing since sliced bread.

The huge majority of uses for either would be better served without them.

[+] wavephorm|14 years ago|reply
Mongo is excellent but I'd argue that Node and CouchDB is even a better fit because there's not even a driver involved, it's one HTTP request which just calls another.
[+] olegp|14 years ago|reply
On a related note, I'm working on a synchronous narwhal-mongodb compatible driver that would work with common-node (http://olegp.github.com/common-node/), Would anyone be interested in helping out?
[+] senko|14 years ago|reply
I'm both Node and MongoDB user and like them, but this can get really messy when there's a chain of callbacks involved, eg when you need a sequence of results but want to do it in a asynchronous fashion.
[+] beyondkaoru|14 years ago|reply
I've been using this:

https://github.com/creationix/step

While I wouldn't quite call it pretty, it keeps things at the same indentation level, and I can still use closures to maintain the illusion of a single "thread".

[+] latch|14 years ago|reply
Is that specific to MongoDB on node, or is that just generally true of node.js code though?
[+] tista|14 years ago|reply
Async behaviors would be a great read up for your next article :D