dresende / node-orm2

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

Unique Associations #356

Open Fauntleroy opened 11 years ago

Fauntleroy commented 11 years ago

Is there any way I can make an association unique? I currently have a setup where a User can like a PlaylistItem via a hasMany association, but I can't prevent that user from being added multiple times. Am I missing something?

playlist_item.addLikers( user, function( err ){
    playlist_item.addLikers( user, function( err ){
        // I can just keep adding the same user
    });
});
spacegangster commented 10 years ago

You can at least set up a UNIQUE key constraint in MySQL.