node.js - Bookshelf.js: how to define cross-relations? -


how can define hasmany space -> accounts relation?

var space = bookshelf.model.extend({     tablename : 'spaces',     // account variable not exist :/ });  var account = bookshelf.model.extend({     tablename : 'accounts',     spaceid   : function() {         return this.belongsto(space);     }, }); 

what correct way define this?

p.s. there no tag bookshelf js library: http://bookshelfjs.org/

according docs, should work:

    var account = bookshelf.model.extend({         tablename : 'accounts'     });      var space = bookshelf.model.extend({         tablename : 'spaces',         accounts  : function() {             return this.hasmany(account, 'spaceid'); // spaceid foreign key account table         }     }); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -