weather_out.js 1.13 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
import { DataTypes, Model } from "sequelize";
import Emd from "./emd";

export class Weather_Out extends Model {
  static init(sequelize) {
    return super.init(
      {
        loc_code: {
          type: DataTypes.INTEGER,
          primaryKey: true,
          references: {
            model: Emd,
13
            key: "code_emd",
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
          },
        },
        collected_at: {
          type: DataTypes.DATE,
          primaryKey: true,
        },
        temp: {
          type: DataTypes.FLOAT,
          defaultValue: 0,
        },
        humi: {
          type: DataTypes.FLOAT,
          defaultValue: 0,
        },
        press: {
          type: DataTypes.FLOAT,
          defaultValue: 0,
        },
        wind_speed: {
          type: DataTypes.FLOAT,
          defaultValue: 0,
        },
      },
      {
        sequelize,
        timestamps: false,
        paranoid: false,
      }
    );
  }

  static associate(db) {
46
    // weather_out 모델이 참조하는 테이블에 대한 외래키 설정.
47
48
    db.Weather_out.belongsTo(db.Emd, {
      foreignKey: "loc_code",
49
      targetKey: "code_emd",
50
51
52
53
54
    });
  }
}

export default Weather_Out;