const Sequelize = require("sequelize");
const db = require("../../db");
const ShopImage = require("../shopimage");


 const Shop = db.sequelize.define("shops", {
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },

  name: {
    type: Sequelize.STRING
  },
  nameeng: {
    type: Sequelize.STRING
  },
  timeopen: {
    type: Sequelize.TIME
  },
  timeclose: {
    type: Sequelize.TIME
  },
  address: {
    type: Sequelize.TEXT
  },
  tel: {
    type: Sequelize.STRING
  },
  detail: {
    type: Sequelize.TEXT
  },
  lat: {
    type: Sequelize.DOUBLE
  },
  lng: {
    type: Sequelize.DOUBLE
  },
  facebook: {
    type: Sequelize.TEXT
  },
  userId: {
    type: Sequelize.INTEGER,
    references: "users",
    referencesKey: "id"
  },
  type: {
    type: Sequelize.ENUM(
      "สปาและนวด",
      "ผิวหน้า",
      "ขนตาและคิ้ว",
      "ทำเล็บ",
      "ชาลอน",
      "แต่งหน้าทำผม"
    )
  }
});

Shop.hasMany(ShopImage, { foreignKey: 'image_id' });

module.exports = Shop;