"use strict";

module.exports = function(sequelize, DataTypes) {
  var Sensor =  sequelize.define('Sensor', {
	identifier: {type: DataTypes.STRING, unique: false, primaryKey: true},
	name: DataTypes.STRING,
	type: DataTypes.INTEGER,
	address: DataTypes.INTEGER,
	lastseq: DataTypes.INTEGER,
	active: DataTypes.BOOLEAN
}, {
    classMethods: {
      associate: function(models) {
        Sensor.belongsTo(models.SensorDetails, {foreignKey: 'type'});
        Sensor.belongsTo(models.SensorLocation, {foreignKey: 'address'});
      }
    }
  });

  return Sensor;
};