5 ms·
Mongo is cool, and Mongoose (node ORM-like wrapper) is pretty nice as well, but after using it for a few months on a project I was building I realized that I wa
by fourstar 13y ago
Mongo is cool, and Mongoose (node ORM-like wrapper) is pretty nice as well, but after using it for a few months on a project I was building I realized that I was duplicating a ton of data. Until mongo solves the issue of joins (something that is better suited to a sql solution), I just had to revert and ended up used node-mysql which is a pretty decent node mysql driver. I was considering using mongo for sessions (with connect-mongo), but ended up going with redis as it's pretty solid solution (and according to some benchmarks, faster).
- diminoten 13y agoIt's not supposed to be a big deal that you're duplicating data. If you want to get the most out of a "document store" like mongodb, you've got to get yourself into a certain frame of mind.
- nevi-me 13y agoDon't think they're going to 'solve' the issue of joins. I think they've taken the decision not to support them. It then becomes an issue of denormalisation, and whether you can actually work on a project with everything denormalised. Otherwise there are some alternatives out there that support joins. I struggled with the concept of denormalisation, as I came from a hobbyist SQL background, but I managed to build a project based on Mongo and Node (https://rwt.to https://rwt.to), and in the process I went from trying very hard to 'make joins work' to hitting the sweet spot of getting my data 'right'. Mongo certainly ain't meant for everything, and I don't know if they'll ever support joins.
- fourstar 13y agoYeah my site is more social-oriented so I can see how your site may work better with something like mongo (if it's mainly lat/long coordinates). Just as a quick example of something I ran into: When saving comments I liked to save the user's _id, username, along with their avatar so I wouldn't have to do a join later on, but then realized what if the user changes their avatar? Since I store the avatar as a row in the `users` collection, then I'd still need to do one of those nasty fake joins. The post/pre-save methods are pretty bad ass and there are a few things I still do like about mongo (which is why I chose to explore it initially), but I think for social type websites, a sql solution makes more sense. I also scoped @ http://www.rethinkdb.com/ http://www.rethinkdb.com/ which looked interesting, but at this time I wanted to go with a more bulletproof solution to my problems.
- nevi-me 13y agoOne way that I keep my data up-to-date is that when I change something in my "station" data (let's say it's an avatar equivalent) I have an update that's triggered across my "route" collection. So you would likely have to do the same. It works well for me, as the reality is that there's always going to be something that changes and needs to be updated. That's why Mongo has decent update queries.
- twerquie 13y agoI feel you - I recently started a node project on LevelDB and ultimately switched over to an SQL database. The difference though is I went for Postgres 9.3, which has incredible native JSON support, allowing you to slice parts of your JSON data out as a record set, join them against tables, as well as other crazy things like partial indexes on deeply nested JSON values which may or may not be present. I really think Pg is starting to blow Mongo out of the water.
- hkarthik 13y agoAny suggestions on ORMs or npm packages to use with pg and node?
- sync 13y agoStars is a great ranking technique, e.g.http://www.node-modules.com/search?q=postgresql&u= http://www.node-modules.com/search?q=postgresql&u=
- dlau1 13y agoI'm using knex [0] which I am pretty happy with. There is also a higher level version built on top of it called bookshelf [1] 0 : https://github.com/tgriesser/knex https://github.com/tgriesser/knex 1 : https://github.com/tgriesser/bookshelf https://github.com/tgriesser/bookshelf
- twerquie 13y agoI'm a big fan of ORMs in other ecosystems (Rails and Django, for example), but in node I like to write more functional-style code, composing small modules into larger applications. For this, check out the fantastic node-postgres adapter from brianc as well as his node-sql package for authoring SQL statements. https://github.com/brianc/node-postgres https://github.com/brianc/node-postgres https://github.com/brianc/node-sql https://github.com/brianc/node-sql
- rpx 13y agoPseudo-joins are possible if you store everything in a nested collection, using aggregations. I highly discourage it.
- sync 13y agoCheck out RethinkDB: http://rethinkdb.com/ http://rethinkdb.com/ Supports joins out of the box, and has much saner locking. It is in its infancy still, but I believe are coming out with a LTS release shortly.
- bovermyer 13y agoI'll second Rethink. I'm using it for a couple different projects, and while it's still technically "unstable," I'm very happy with its performance. Also, it's just fun to work with.