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

Relationships in MongoDB are commonly stored as ObjectID references, and (at least on node) the default Mongo client (Mongoose) makes you write schemas to enforce these.

I think Mongo is awful too, and I'm sure there are problems with this approach - I'd love for someone with more DB knowledge to go into details - but saying there are 'no relations' seems to be an oversimplification.



Mongoose is a client-side library. It emulates relations and schemas client-side, as I also pointed out in the article.This also means that the database cannot optimize for relations and schemas, as it doesn't even know they exist.

Mongoose is also very much not the default MongoDB client in Node.js - it's a third-party client library by Automattic. The official client according to the MongoDB documentation is `mongodb` (https://www.npmjs.com/package/mongodb), which does not feature relations.


I have used and am aware of node-mongodb-native (I wrote http://stackoverflow.com/questions/19546561/node-mongodb-err... where we discovered it wrapped and threw away all exceptions in callbacks in the stable production version ), but Mongo (the company) have recommended Mongoose. The language now is vaguer than it was 'you can use it natively if you want, or use Mongoose' http://docs.mongodb.org/ecosystem/drivers/node-js/

Thanks for your excellent explanation and totally understood re: not being able to optimise for relationships on the server.


I actually didn't even notice Mongoose being mentioned on that page, to be honest, given that the instructions were for `mongodb`. I'd imagine that neither would a developer skimming the page :)


Mongoose isn't the default Node.js MongoDB driver, though it is very popular.




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

Search: