"use strict";

module.exports = function(sequelize, DataTypes) {
  var Page =  sequelize.define('Page', {
	id: {type: DataTypes.STRING, unique: false, autoIncrement: true, primaryKey: true},
	titulo: DataTypes.STRING(50),
	url: DataTypes.STRING(100),
	contenido: DataTypes.TEXT,
	tipo: DataTypes.INTEGER(2),
	plantilla: DataTypes.STRING(100),
  }, {
    classMethods: {
      associate: function(models) {
        Page.belongsTo(models.PageType, {foreignKey: 'tipo'});
        Page.hasMany(models.PageChart, {foreignKey: 'idPage'});
      }
    }
  });

  return Page;
};