Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

i'm curious, why do you recommend the mongo native driver instead of mongoose?


Mongoose is great and should be also checked out.

To get this paradigm shift and the entire experience with Node, NoSQL and especially Node in combination with Mongo the Native Driver is essential:

Mongoose is great and basically an ORM (or they call it ODM, Object Document Mapper) which forces you for good reasons to do a little more preparations like doing a scheme and so on. Point is that's highly recommended as migrations are with SQL counterparts but the point is for the 90% of the projects you start you do not know:

- Will you ever finish the project?

- Will the project ever be deployed?

- Will you ever get heavy traffic and traction?

Often especially with private side projects you just play around and try. Client projects most of the times never reach web scale (and if they reach refactoring and optimizing is easy). Then, most important is is just to get started and the Native Driver is then the best choice because it totally rewires your brain. No scheme, just start. Want another field? Just save another key to this document (=record). Want a join to give users multiple options in a field? Just use an array. Want to save pictures in the DB and not in the filesystem with creating some file organization script, just put them in Mongo with GridFS too (which is fast btw). Let's not forget that Mongos JS interface and JSON data structure are very close to JS and do not feel low level, so native driver isn\t a low lewel driver, it basically provides the original Mongo JS interface which is very convenient and not low lewel at all. You don't have validations but as soon as you need them switch to Mongoose or write them yourself.

To get a proper db model and architecture it's definitely better to a design nice relational data model, use SQL, do migrations and if performance required, put some NoSQL or Redis in between (or whatever). BUT: this is all work and even with Rails where migrations are kind of easy, it is work beforehand and you have to plan a godd structure. This often prevents you just from starting and with the native driver you just start and in ridiculously many cases a plain document orientated data model is fully sufficient and even for those which would require rather a RDBMS this can be tweaked. Performance should never be a problem.

Point is: the classic approach with SQL, data models, mapping, ORMs is good but prevents you from just starting, "sketching" you program and getting out of the door. Latter is more fun and gets things done. Maybe later you have to refactor when a project is successful. But this is easier than doing all projects always in a structured and formal manner. And even if you will use Mongoose all the time it is good that you experienced once the Native Driver, that you know this thing exists and using Mongo with its native interface is as easy as using a toy.


ok thanks for replying I see your point. We are currently developing a project that hopefully will reach web scale (that is the goal anyway) and we started out with mongoose (without really thinking about it though) because it brings you a lot of nice things such as hooks, validators, setters and getters. Of course from an experimentation point of view, what you said makes a lot of sense given my experience with mongoose.


mongoose is an ORM, so they're not the same thing. mongoose depends on native driver anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: