summaryrefslogblamecommitdiffstats
path: root/server/models/client.js
blob: a7c9d4bfec7fe0420bc28432c58769b7e6db8c0d (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                            
                                        

                          

                                       


                     
                                        
                                                                                                           
                                                                                                                            
                                                     

                                                                                                                                         


               
'use strict'
module.exports = (sequelize, DataTypes) => {
  var client = sequelize.define('client', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: DataTypes.INTEGER
    },
    name: DataTypes.STRING,
    description: DataTypes.STRING(2048),
    ip: DataTypes.STRING,
    mac: DataTypes.STRING,
    uuid: DataTypes.STRING,
    registrationState: DataTypes.STRING
  }, {
    timestamps: false
  })
  client.associate = function (models) {
    var GroupXClient = sequelize.define('group_x_client', {}, { timestamps: false, freezeTableName: true })
    client.belongsToMany(models.group, { as: 'groups', through: GroupXClient, foreignKey: 'clientId', otherKey: 'groupId' })
    client.belongsTo(models.config, { as: 'config' })
    var ClientXEvent = sequelize.define('client_x_event', { blacklist: DataTypes.BOOLEAN }, { timestamps: false, freezeTableName: true })
    client.belongsToMany(models.event, { as: 'events', through: ClientXEvent, foreignKey: 'clientId', otherKey: 'eventId' })
  }
  return client
}