Which ORM for node.js? [closed]
Bookshelf should currently support all of those:
- The mapping of columns to property names with theformat andparse methods.
- Using a different table name with thetableName attribute.
- Timestamping can take custom columns with thehasTimestampattribute.
- Foreign keys can be defined withknex schema builder... they're not well documented but you cansee an example in the tests here
- Supports mysql, sqlite and postgres
Definitely supports one model per file... the relations are defined in methods, so you can do:
var Classroom = Bookshelf.Model.extend({ tableName: 'classrooms', student: function() { // Relating to a model from a file in the same directory. return this.hasMany(require('./student')); }});new Classroom({id: 1}) .fetch({withRelated: ['students']) .then(function(classroom) { console.log(JSON.stringify(classroom)); });
Official soft delete support is in the works, but is definitely easily achieved by extending the model and providing a new destroy method like so:
destroy: function(options) { if (options.softDelete) { return this.save({'deleted_at': new Date}); } return bookshelf.Model.prototype.destroy.call(this, arguments);}
It doesn't hook into a cache yet, because cache invalidation on relations is pretty tricky, definitely something under consideration.
If you see anything that seems to be missing, feel free to open a ticket.
You may take a look at light-orm: https://github.com/knyga/light-ormSimple ORM. Don't create foreign keys. Can't map properties to column names. But could be connected to any rdbms, and super simple.