dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 376 forks source link

Is there a way to define composite unique keys on merge/join tables? #520

Open mike-zenith opened 10 years ago

mike-zenith commented 10 years ago

I want to create a 'hasMany' association thru a table which has composite, user defined unique keys

Im currenlty using a workaround with hooks to reach the same effect

eg:

var User = db.define('user', {
       name: { type: 'string', size: 32 }
});

var Badge = db.define('badge' {
       name: { type: 'string', size: 32 }
});

User.hasMany('badges', Badge, {
       level: { type: 'integer', size: 1 }
}, { reverse: true, unique: ['user_id', 'badges_id', 'level' ] });
dxg commented 10 years ago

Not that I'm aware of.