News for hackers. Stuff that matters.
Re:Never, ever, ever use MongoDB by nailer on Sunday July 19, 2015 @06:34PM (#9913105)
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.

Re:Never, ever, ever use MongoDB by joepie91_ on Sunday July 19, 2015 @06:41PM (#9913130)
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.

Re:Never, ever, ever use MongoDB by nailer on Sunday July 19, 2015 @06:52PM (#9913167)
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.

Re:Never, ever, ever use MongoDB by joepie91_ on Sunday July 19, 2015 @07:06PM (#9913206)
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 :)
Re:Never, ever, ever use MongoDB by phillips1012 on Sunday July 19, 2015 @06:37PM (#9913118)
Mongoose isn't the default Node.js MongoDB driver, though it is very popular.