dresende/node-orm2

How to set multiple unique index with auto generated column from `.hasOne()` method.

reumia opened this issue · 1 comments

I made associations like this.

const LikesComic = db.models['likes_comic']

LikesComic.hasOne('target', Comics)
LikesComic.hasOne('user', Users)

then, target_id and user_id columns are created automatically on likes_comic table.

and I want to set multiple unique index like this.

// if these columns - user_id & target_id - are not created automatically,
db.define('likes_comic', {
  user_id: {type: 'integer', unique: 'user_id_target_id'},
  target_id: {type: 'integer', unique: 'user_id_target_id'}
})

my currently defining is like above.

db.define('likes_comic', {
  // nothings on here.
})

is there any way to do this?

moved to #816