summaryrefslogtreecommitdiffstats
path: root/server/models/client.js
blob: 10860232fa9d7019af869c00e7c4c9820582968b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict'
module.exports = (sequelize, DataTypes) => {
  var client = sequelize.define('client', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: DataTypes.INTEGER
    },
    name: DataTypes.STRING,
    ip: DataTypes.STRING,
    mac: DataTypes.STRING,
    uuid: 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'})
  }
  return client
}