News for hackers. Stuff that matters.
Re:Node.js, MongoDB, and you: an intro in parts by fourstar on Thursday January 16, 2014 @02:32PM (#7071920)
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).
Re:Node.js, MongoDB, and you: an intro in parts by twerquie on Thursday January 16, 2014 @02:54PM (#7072090)
I 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.

Re:Node.js, MongoDB, and you: an intro in parts by hkarthik on Thursday January 16, 2014 @03:56PM (#7072503)
Any suggestions on ORMs or npm packages to use with pg and node?
Re:Node.js, MongoDB, and you: an intro in parts by twerquie on Friday January 17, 2014 @01:25PM (#7077465)
I'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-sql

Re:Node.js, MongoDB, and you: an intro in parts by sync on Thursday January 16, 2014 @04:34PM (#7072693)
Stars is a great ranking technique, e.g.http://www.node-modules.com/search?q=postgresql&u=
Re:Node.js, MongoDB, and you: an intro in parts by dlau1 on Thursday January 16, 2014 @09:01PM (#7073839)
I'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 1 : https://github.com/tgriesser/bookshelf

Re:Node.js, MongoDB, and you: an intro in parts by nevi-me on Thursday January 16, 2014 @02:43PM (#7071998)
Don'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), 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.

Re:Node.js, MongoDB, and you: an intro in parts by fourstar on Thursday January 16, 2014 @02:53PM (#7072067)
Yeah 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/ which looked interesting, but at this time I wanted to go with a more bulletproof solution to my problems.

Re:Node.js, MongoDB, and you: an intro in parts by nevi-me on Thursday January 16, 2014 @03:40PM (#7072373)
One 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.
Re:Node.js, MongoDB, and you: an intro in parts by diminoten on Thursday January 16, 2014 @02:39PM (#7071972)
It'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.
Re:Node.js, MongoDB, and you: an intro in parts by sync on Thursday January 16, 2014 @04:14PM (#7072590)
Check out RethinkDB: 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.

Re:Node.js, MongoDB, and you: an intro in parts by bovermyer on Thursday January 16, 2014 @04:17PM (#7072607)
I'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.

Re:Node.js, MongoDB, and you: an intro in parts by rpx on Thursday January 16, 2014 @03:52PM (#7072465)
Pseudo-joins are possible if you store everything in a nested collection, using aggregations. I highly discourage it.