primaryKey

By default, the field id is used as primary key.

Usage

simple

class User extends Model {
  static entity = 'users'
  static primaryKey = 'userId'
  static fields () {
    return {
      userId: this.attr(null)
    }
  }
}

combined

class RoleUser extends Model {
  static entity = 'roleUser'
  static primaryKey = ['role_id', 'user_id']
  static fields () {
    return {
      role_id: this.attr(null),
      user_id: this.attr(null)
    }
  }
}

Typescript Declarations

const primaryKey: string | string[] = 'id'