summaryrefslogtreecommitdiffstats
path: root/server/models/registrationhook.js
blob: 25fc0f0bb58ca6382a8606e8b0e8db6ca5295a47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict'
module.exports = (sequelize, DataTypes) => {
  var registrationhook = sequelize.define('registrationhook', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: DataTypes.INTEGER
    },
    name: DataTypes.STRING,
    description: DataTypes.STRING(2048),
    sortvalue: DataTypes.INTEGER,
    type: DataTypes.STRING,
    script: {
      allowNull: true,
      type: DataTypes.BLOB,
      get () {
        var blob = this.getDataValue('script')
        return blob ? blob.toString() : ''
      }
    }
  }, {
    timestamps: false
  })
  registrationhook.associate = function (models) {
    var RegistrationhookXGroup = sequelize.define('registrationhook_x_group', {}, { timestamps: false, freezeTableName: true })
    registrationhook.belongsToMany(models.group, { as: 'groups', through: RegistrationhookXGroup, foreignKey: 'registrationhookId', otherKey: 'groupId' })
  }
  return registrationhook
}