I'm seeking for a good ORM for postgres under Node.js, one that supports declaration of relationships beetween models, and fields validation. I've searched during a long time and cannot get any satisfying results. Maybe someone can point me to a project I missed during my researches. Thx.
8 Answers
node-orm2 looks good: supports association, validators, and mysql, postgres, and mongo (in beta)
UPDATE: The node-orm2
package is no longer maintained. Possible alternatives include bookshelf or sequelize.
-
1Currently, it does not feed PG with
DEFAULT
values on insertion when a value is not provided– kolyptoCommented Nov 18, 2013 at 22:48 -
@kolypto Looks like there's workaround for that. github.com/dresende/node-orm2/issues/391 Commented Mar 4, 2014 at 7:24
-
SequelizeJS - models, validation and migrations
BookshelfJS - a promise based ORM looks quite promising
-
4A note regarding sequelize - its implementations of associations are incredibly buggy and I could not get them to work at all in my project.– TJCCommented Dec 29, 2013 at 18:27
-
JugglingDB - multidatabase ORM inspired by activerecord and datamapper. Supports validations, hooks, relations. Works with: mysql, postgres, sqlite, memory, redis, mongodb, neo4j.
Not production ready now (march 2012), but growing fast. I plan stable release soon.
-
Currently, it assumes that your PK column is named
id
, and that's hardcoded– kolyptoCommented Nov 18, 2013 at 22:48
Would recommend trying Knex for the database and Bookshelf as an ORM on top of it (developed by same person). I'm using it with postgres, but supports SQLite, MySQL/MariaDB and Oracle (in alpha) too.
Very expressive promise-based API with bluebird
behind it, knex has a well documented and great command line tool for making migrations, seed files etc. Bookshelf uses backbone models and collections as an inspiration, including the .extend(..)
paradigm for inheritance, so picking it up is a breeze if you come from that world. So far, so good.
-
Have you an App tha use BS?,....how is its performance? Commented Jun 3, 2016 at 2:05
-
Missy is a universal ORM for both SQL and NoSQL databases which is simple, flexible, well-documented and supports some fancy features that other ORMs are lacking
ORM's are a little too slow for fast nature of node.js; plain database driver is fine, but a little tiring. That's for I do write something just between: prego. It provides automatic statement preparation, migrations, simple models with associations, transactions and few utilities, all callback style and fast. Ideas/issues are welcome.
https://www.npmjs.org/package/rdb
Simple, flexible mapper.
Transaction with commit and rollback.
Persistence ignorance - no need for explicit saving, everything is handled by transaction.
Eager or lazy loading.
Based on promises.
Well documented by (running) examples.