Best Node.js ORM for MySQL

5,214 views
Skip to first unread message

Steve Keiser

unread,
Oct 8, 2013, 1:18:45 PM10/8/13
to uta...@googlegroups.com
Hey guys,

It's been a few years since this question has been asked: Does anyone know of a great ORM for MySQL in Node.js? I'm currently using Sequelize, but I'm not convinced it's the best. Does anyone have experience with Waterline or others?

Thanks,
Steve

Sean Clark Hess

unread,
Oct 8, 2013, 2:16:50 PM10/8/13
to UtahJS
I'm assuming switching databases is out of the question? I haven't ever used an ORM with node because it's so easy using a document store. I highly recommend http://www.rethinkdb.com if you still have the choice. 

Sorry I'm not more help on the ORM selection though. 


--
Group meets on the 1st Thursday and 3rd Tuesday of each month. See http://utahjs.com/location/ for more info.
---
You received this message because you are subscribed to the Google Groups "Utah JavaScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to utahjs+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/utahjs.

David Stevens

unread,
Oct 8, 2013, 2:39:48 PM10/8/13
to uta...@googlegroups.com
Amazon AWS has DynamoDB for their in-house NoSQL solution. Or you can run any NoSQL database on an EC2 instance.


- david


On Tue, Oct 8, 2013 at 12:30 PM, Steve Keiser <m...@stevekeiser.com> wrote:
Weeeellll, it's not out of the question. It's just that NoSQL databases still freak me out. Haha. I'm used to a normalized world, and it seems like document stores all lean toward denormalization/chaos. We plan to use Amazon Web Services and take advantage of RDS... which doesn't support NoSQL. If anyone has thoughts on converting from a SQL to a NoSQL mentality, I'm all ears. But thanks for the recommendation, Sean. I'll definitely take the time to look into it.


You received this message because you are subscribed to a topic in the Google Groups "Utah JavaScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/utahjs/R_-7l4BcvLQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to utahjs+un...@googlegroups.com.

Sean Clark Hess

unread,
Oct 8, 2013, 3:00:31 PM10/8/13
to UtahJS
Sure man, totally understand. Not to push the point too far, but unlike MongoDB, Rethinkdb has joins groups, and other fancy features. I usually normalize most things (example: I don't store comments under the post objects, I put them in the comments table), but it's nice to be able to denormalize some things, like an array of tags. 

To maintain the "chaos", I use Typescript to provide schema enforcement at the application layer. It's really easy to add Typescript to a project if the only thing you do is create some interfaces and add "var user:IUser = ..." to a couple places in your code. I usually want enforcement at the application layer anyway, so it's nice to only have it in one place. 

Anyway, RethinkDB has amazing features, a great query language, and super performance. The team is great, and they've been adding cool stuff non-step. I agree with their goals and tradeoffs. Can't gush enough about that thing, especially in contrast to MongoDB. 


On Tue, Oct 8, 2013 at 12:30 PM, Steve Keiser <m...@stevekeiser.com> wrote:
Weeeellll, it's not out of the question. It's just that NoSQL databases still freak me out. Haha. I'm used to a normalized world, and it seems like document stores all lean toward denormalization/chaos. We plan to use Amazon Web Services and take advantage of RDS... which doesn't support NoSQL. If anyone has thoughts on converting from a SQL to a NoSQL mentality, I'm all ears. But thanks for the recommendation, Sean. I'll definitely take the time to look into it.
On Tue, Oct 8, 2013 at 12:16 PM, Sean Clark Hess <sean...@gmail.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "Utah JavaScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/utahjs/R_-7l4BcvLQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to utahjs+un...@googlegroups.com.

Jamison Dance

unread,
Oct 8, 2013, 3:01:02 PM10/8/13
to uta...@googlegroups.com
We have a talk on getting started with AWS at next month's UtahJS South meetup if anyone wants to learn more about (ノ◕ヮ◕)ノ*:・゚✧ THE CLOUD (ಥ﹏ಥ).

Sean Clark Hess

unread,
Oct 8, 2013, 3:01:22 PM10/8/13
to UtahJS
Oh, and if you need an AWS alternative I've been really happy with http://digitalocean.com/

David Stevens

unread,
Oct 8, 2013, 3:07:31 PM10/8/13
to uta...@googlegroups.com
+1 on digitalocean.com

AWS has some nice features and integration between services, but I much prefer digitalocean given the choice.


- david

Dan Fellars

unread,
Oct 8, 2013, 3:14:50 PM10/8/13
to uta...@googlegroups.com

Sean – I’ve casually looked at RethinkDB as a replacement for MongoDB, but I rely heavily on the $elemMatch query in mongo and at a quick look could not find something similar in Rethink.  Do you know a way to do similar in Rethink?

 

Otherwise it has does look impressive. 

 

Also +1 for DigitalOcean

 

Dan

Steve Keiser

unread,
Oct 8, 2013, 2:30:10 PM10/8/13
to uta...@googlegroups.com
Weeeellll, it's not out of the question. It's just that NoSQL databases still freak me out. Haha. I'm used to a normalized world, and it seems like document stores all lean toward denormalization/chaos. We plan to use Amazon Web Services and take advantage of RDS... which doesn't support NoSQL. If anyone has thoughts on converting from a SQL to a NoSQL mentality, I'm all ears. But thanks for the recommendation, Sean. I'll definitely take the time to look into it.
On Tue, Oct 8, 2013 at 12:16 PM, Sean Clark Hess <sean...@gmail.com> wrote:
You received this message because you are subscribed to a topic in the Google Groups "Utah JavaScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/utahjs/R_-7l4BcvLQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to utahjs+un...@googlegroups.com.

Sean Clark Hess

unread,
Oct 8, 2013, 3:34:59 PM10/8/13
to UtahJS
I've always been happier (even in Mongo) putting the embedded documents in their own table/collection by the time I need $elemMatch. It's more flexible and more efficient. 

It doesn't look like RethinkDB can current do $elemMatch, no. :(

Clint Berry

unread,
Oct 9, 2013, 11:11:12 AM10/9/13
to uta...@googlegroups.com
I agree with Sean. Whenever I get any significant amount of data in Mongo, queries on those embedded docs get slow. We always end up using separate collections, or duplicating the data into a separate collection as well. 

One thing mongo has (if you need it) is geospacial indexes which is awesome if you are doing geo-location stuff at all. Also, aggregate upserts are nice if you are creating any sort of analytics data store.

I've never used Rethink, but I'll give it a look.


Jamison Dance

unread,
Oct 9, 2013, 11:14:59 AM10/9/13
to uta...@googlegroups.com
I have reached the Mongo trough of despair. Right now I can't think of a reason to use it on a new project besides familiarity, but I feel like pretty much everything it does is done better by other databases. Maybe the grass is always greener though.

Sean Clark Hess

unread,
Oct 9, 2013, 12:20:17 PM10/9/13
to UtahJS
@Jamison - RethinkDB is just hands down better. Seriously. I still haven't fallen out of love with the idea of document stores, I just miss joins, and Mongo didn't turn out to be as easily scalable as it said. Once you see how easy sharding is in RethinkDB you'll freak out. 

@Clinet - Totally. Mongo's $elemMatch, for example, can't use an index. The promise of storing these massive nested documents as mini-tables was never actually real. See my blog on the subject. http://seanhess.github.com/2012/02/01/mongodb_relational.html. Some things are out of date ($elemMatch makes this possible now), but I still think the approaches are they same.

Sean Clark Hess

unread,
Oct 9, 2013, 12:36:12 PM10/9/13
to UtahJS
Whoops. I totally misread $elemMatch. RethinkDB can totally do that, and with a much simpler construct: filter! From the docs: http://rethinkdb.com/api/#js:selecting_data-filter

Example: Select all documents where the field 'powers' containing an array has an element equal to 10.


r.table('marvel').filter(
  r.row('poweres').filter(
    function(powers_el) { return powers_el.eq(10) }
  ).count().gt(0)
).run(conn, callback)

What neither $elemMatch nor Rethink do is restrict the elements of the nested array returned. They return the full array for each matched document. 

MongoDB has an aggregation framework that can do the above, but I'm pretty sure you don't get any performance advantage over returning the whole array, and it's certainly slower than putting them in a separate collection/table.


Dan Fellars

unread,
Oct 9, 2013, 12:48:15 PM10/9/13
to uta...@googlegroups.com

Very cool.  I’ll definitely be keeping an eye on RethinkDB.

Clint Berry

unread,
Oct 9, 2013, 12:50:00 PM10/9/13
to uta...@googlegroups.com
Sean, RethingDB doesn't have automatic failover to slaves though? That is a deal breaker in my mind. Every database I can think of has some sort of failover system...

Sean Clark Hess

unread,
Oct 9, 2013, 1:47:50 PM10/9/13
to UtahJS
You're right. It's on the roadmap for production readiness. You can currently manually manage failover through the CLI or web tool, and it seems easy to set up some kind of alert to know when one of the replicas goes down. 


I wouldn't be surprised if they reach 2.0 (the production release) pretty soon though. The pace at which they've been advancing is really impressive. I've never seen any project move so quickly, especially for something as complicated as a database. 

Joshua Holbrook

unread,
Oct 9, 2013, 1:53:09 PM10/9/13
to uta...@googlegroups.com
My $0.02:

I don't think there are any great ORMs for node. One reason is what
you've already seen: noders tend to use lots of different kinds of
databases and it's really hard to one-size-fits-all an ORM/ODM against
even the most common dbs. The other, of course, is that noders tend to
dislike ORMs because they're "too heavyweight".

One of the more active/complete ORM/ODMs is
https://github.com/1602/jugglingdb . IMO it's terrible.

Best of luck!

--Josh

Ryan Florence

unread,
Oct 9, 2013, 7:32:13 PM10/9/13
to uta...@googlegroups.com
It is hard to justify anything but Postgres these days: hstore, array, and json data types, proven scalability, relational when you need it, etc etc etc

Sent from my iPhone

Stanley Stuart

unread,
Oct 9, 2013, 7:34:29 PM10/9/13
to uta...@googlegroups.com, Joshua Holbrook
Haven't used it, but Sails JS works on Waterline, which supposedly works with a bunch of different backends.

-- 
Stanley Stuart

Clint Berry

unread,
Oct 9, 2013, 11:06:38 PM10/9/13
to uta...@googlegroups.com
CouchDB seems cool too. Master master replication, http requests to store and read data. But I haven't ever used it.

We do use postgres here at my work and it does great. Handles millions of call records too. We have been happy.


On Wed, Oct 9, 2013 at 9:06 PM, Clint Berry <cl...@system-11.com> wrote:
CouchDB seems cool too. Master master replication, http requests to store and read data. But I haven't ever used it.

We do use postgres here at my work and it does great. Handles millions of call records too. We have been happy.

Sean Clark Hess

unread,
Oct 10, 2013, 8:23:10 AM10/10/13
to uta...@googlegroups.com
I've tried using couch on a big project, and it's just that: cool. But it isn't like a traditional database. It makes it easier to do some really fancy stuff, like syncing data, and harder to do most normal things. 
>>> On Wed, Oct 9, 2013 at 10:20 AM, Sean Clark Hess <seanhess@gmail.c

Randall Bennett

unread,
Oct 10, 2013, 9:14:26 AM10/10/13
to uta...@googlegroups.com
+1 to Ryan.

David Stevens

unread,
Oct 10, 2013, 10:18:47 AM10/10/13
to uta...@googlegroups.com
Agree on Postgres, especially with JSON support.

And Steve, to your point about using AWS, RDS doesn't currently support Postgres, but you can run Postrgres on an EC2 instance using EBS if you need more storage. RDS is really just a 'special' version of EC2 anyway. Postgres has far better built-in backup and replication than MySQL so the advantages of automatic backups (etc) built into RDS are more than compensated for with Postgres' superior functionality.



- david

Joshua Holbrook

unread,
Oct 10, 2013, 12:22:28 PM10/10/13
to uta...@googlegroups.com
Having worked for one of the biggest users of couch, I more or less
agree. Couch is great if you have a bunch of relatively small
documents where you don't need ad-hoc queries. So it works pretty good
for npm because npm documents consist mostly of package.json documents
with attachments, and most of the things you'd want to know lend
themselves well to the cached view index model (search is an
exception). On the other hand, it's not great if your documents are
large (indexing them is expensive), or if you're expecting
non-enumerable query parameters (example: Querying for geographical
regions containing some lat/long).

I love couch, but I appreciate the existence of large swaths of
problems you won't run into anywhere else.

--Josh

Charles Wood

unread,
Oct 10, 2013, 12:43:00 PM10/10/13
to uta...@googlegroups.com
Ok, so this thread totally go hijacked into OMGWTFBBQDB?

Just out of curiosity, are there ORM's out there for SQL databases like Postgres on Node.js?

Clint Berry

unread,
Oct 10, 2013, 1:16:36 PM10/10/13
to uta...@googlegroups.com
ha ha, sorry Charles. It is a good discussion though.

Here is a good list. I've never found anything like Doctrine, or Django ORM, probably due to the reasons Joshua said. 


Looks like JugglingDB and Persist are some options for relational DBs

Jamison Dance

unread,
Oct 10, 2013, 1:18:53 PM10/10/13
to uta...@googlegroups.com
Sequelize (http://sequelizejs.com/documentation) and node-orm2 (https://github.com/dresende/node-orm2) are the most popular that I am aware of. I don't have experience with either of them though.

James Brinkerhoff

unread,
Oct 10, 2013, 1:21:53 PM10/10/13
to uta...@googlegroups.com

Yeah, there are a few ORM's out there:

Charles Wood

unread,
Oct 10, 2013, 2:09:39 PM10/10/13
to uta...@googlegroups.com
Yeah, don't get me wrong, I love the db discussions, but I was curious about orms too.


On Thu, Oct 10, 2013 at 11:18 AM, Jamison Dance <jerg...@gmail.com> wrote:
Sequelize (http://sequelizejs.com/documentation) and node-orm2 (https://github.com/dresende/node-orm2) are the most popular that I am aware of. I don't have experience with either of them though.

--

David Stevens

unread,
Nov 14, 2013, 5:09:12 PM11/14/13
to uta...@googlegroups.com
I know this is an old thread but, because it came up here as a topic, I'm just providing an update for any interested that AWS just announced support for PostgreSQL on RDS. So now you get proper support for a proper database.


- david


--

Steve Keiser

unread,
Nov 14, 2013, 5:23:08 PM11/14/13
to uta...@googlegroups.com, d...@vidcstevens.com
Woah, sweet! That's good news. Thanks for the heads up, David!

Gabriel Gunderson

unread,
Nov 15, 2013, 5:09:36 AM11/15/13
to uta...@googlegroups.com
On Thu, Nov 14, 2013 at 3:23 PM, Steve Keiser <m...@stevekeiser.com> wrote:
Woah, sweet! That's good news. Thanks for the heads up, David!

YES. Very cool. Thanks!


Gabe

Oleksandr Knyga

unread,
Jan 27, 2014, 3:58:04 AM1/27/14
to uta...@googlegroups.com
Bookshelf (for big db): https://npmjs.org/package/bookshelf
Light-orm (for small db): https://npmjs.org/package/light-orm

вторник, 8 октября 2013 г., 20:18:45 UTC+3 пользователь Steve Keiser написал:

Ken Snyder

unread,
Jan 27, 2014, 2:27:56 PM1/27/14
to uta...@googlegroups.com
Bookshelf looks really awesome. It is comprehensive and I like how promises are built in.


--

Oleksandr Knyga

unread,
Jan 30, 2014, 5:37:58 AM1/30/14
to uta...@googlegroups.com
Light-orm is also pretty good, more flexible.

понедельник, 27 января 2014 г., 21:27:56 UTC+2 пользователь Ken Snyder написал:

Will Schmid

unread,
Oct 1, 2014, 2:37:41 AM10/1/14
to uta...@googlegroups.com
Try Oreo: 
https://github.com/will123195/oreo

- Detects tables and foreign keys
- Detects master/slaves
- Very simple to use
Reply all
Reply to author
Forward
0 new messages