Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
eue
Commits
d8cebce9
Commit
d8cebce9
authored
Jul 11, 2021
by
KangMin An
Browse files
Update : Table & Column 이름 정정. 주석 수정.
parent
541c4207
Changes
8
Show whitespace changes
Inline
Side-by-side
server/src/db/index.js
View file @
d8cebce9
...
@@ -56,6 +56,7 @@ Weather_out.associate(db);
...
@@ -56,6 +56,7 @@ Weather_out.associate(db);
// Messages for Data Base.
// Messages for Data Base.
const
msg
=
{
const
msg
=
{
connection_success
:
"
DB Connection Success.
"
,
connection_err
:
"
DB Connection Error.
"
,
connection_err
:
"
DB Connection Error.
"
,
query_success
:
"
DB Query Success.
"
,
query_success
:
"
DB Query Success.
"
,
query_err
:
"
DB Querry Error.
"
,
query_err
:
"
DB Querry Error.
"
,
...
...
server/src/init.js
View file @
d8cebce9
...
@@ -13,11 +13,12 @@ const handleListening = () => {
...
@@ -13,11 +13,12 @@ const handleListening = () => {
// DB 연결
// DB 연결
db
.
sequelize
db
.
sequelize
.
sync
({
force
:
fals
e
})
.
sync
({
force
:
tru
e
})
.
then
(()
=>
{
.
then
(()
=>
{
console
.
log
(
"
DB Connect Suceecs!
"
);
console
.
log
(
db
.
msg
.
connection_success
);
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
console
.
log
(
db
.
msg
.
connection_err
);
console
.
log
(
err
);
console
.
log
(
err
);
});
});
...
...
server/src/models/doe.js
View file @
d8cebce9
...
@@ -11,12 +11,12 @@ export class Doe extends Model {
...
@@ -11,12 +11,12 @@ export class Doe extends Model {
static
init
(
sequelize
)
{
static
init
(
sequelize
)
{
return
super
.
init
(
return
super
.
init
(
{
{
code
:
{
code
_doe
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
allowNull
:
false
,
primaryKey
:
true
,
primaryKey
:
true
,
},
},
name_do
:
{
name_do
e
:
{
type
:
DataTypes
.
STRING
(
20
),
type
:
DataTypes
.
STRING
(
20
),
allowNull
:
false
,
allowNull
:
false
,
},
},
...
@@ -30,16 +30,16 @@ export class Doe extends Model {
...
@@ -30,16 +30,16 @@ export class Doe extends Model {
}
}
static
associate
(
db
)
{
static
associate
(
db
)
{
// 모델
이
참조
되
는 테이블 설정
//
Doe
모델
을
참조
하
는 테이블
들에 대한 외래키
설정
db
.
Doe
.
hasMany
(
db
.
Sgg
,
{
db
.
Doe
.
hasMany
(
db
.
Sgg
,
{
foreignKey
:
"
code_do
"
,
foreignKey
:
"
code_do
e
"
,
sourceKey
:
"
code
"
,
sourceKey
:
"
code
_doe
"
,
onDelete
:
"
CASCADE
"
,
onDelete
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
});
});
db
.
Doe
.
hasMany
(
db
.
Emd
,
{
db
.
Doe
.
hasMany
(
db
.
Emd
,
{
foreignKey
:
"
code_do
"
,
foreignKey
:
"
code_do
e
"
,
sourceKey
:
"
code
"
,
sourceKey
:
"
code
_doe
"
,
onDelete
:
"
CASCADE
"
,
onDelete
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
});
});
...
...
server/src/models/emd.js
View file @
d8cebce9
...
@@ -13,7 +13,7 @@ export class Emd extends Model {
...
@@ -13,7 +13,7 @@ export class Emd extends Model {
static
init
(
sequelize
)
{
static
init
(
sequelize
)
{
return
super
.
init
(
return
super
.
init
(
{
{
code
:
{
code
_emd
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
allowNull
:
true
,
allowNull
:
true
,
primaryKey
:
true
,
primaryKey
:
true
,
...
@@ -32,26 +32,26 @@ export class Emd extends Model {
...
@@ -32,26 +32,26 @@ export class Emd extends Model {
}
}
static
associate
(
db
)
{
static
associate
(
db
)
{
// 모델이 참조하는 테이블
//
emd
모델이 참조하는 테이블
에 대한 외래키 설정
db
.
Emd
.
belongsTo
(
db
.
Doe
,
{
db
.
Emd
.
belongsTo
(
db
.
Doe
,
{
foreignKey
:
"
code_do
"
,
foreignKey
:
"
code_do
e
"
,
targetKey
:
"
code
"
,
targetKey
:
"
code
_doe
"
,
});
});
db
.
Emd
.
belongsTo
(
db
.
Sgg
,
{
db
.
Emd
.
belongsTo
(
db
.
Sgg
,
{
foreignKey
:
"
code_sgg
"
,
foreignKey
:
"
code_sgg
"
,
targetKey
:
"
code
"
,
targetKey
:
"
code
_sgg
"
,
});
});
// 모델
이
참조
되
는 테이블
//
emd
모델
을
참조
하
는 테이블
에 대한 외래키 설정
db
.
Emd
.
hasMany
(
db
.
User
,
{
db
.
Emd
.
hasMany
(
db
.
User
,
{
foreignKey
:
"
loc_code
"
,
foreignKey
:
"
loc_code
"
,
sourceKey
:
"
code
"
,
sourceKey
:
"
code
_emd
"
,
onDelete
:
"
CASCADE
"
,
onDelete
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
});
});
db
.
Emd
.
hasMany
(
db
.
Weather_out
,
{
db
.
Emd
.
hasMany
(
db
.
Weather_out
,
{
foreignKey
:
"
loc_code
"
,
foreignKey
:
"
loc_code
"
,
sourceKey
:
"
code
"
,
sourceKey
:
"
code
_emd
"
,
onDelete
:
"
CASCADE
"
,
onDelete
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
});
});
...
...
server/src/models/sgg.js
View file @
d8cebce9
...
@@ -13,7 +13,7 @@ export class Sgg extends Model {
...
@@ -13,7 +13,7 @@ export class Sgg extends Model {
static
init
(
sequelize
)
{
static
init
(
sequelize
)
{
return
super
.
init
(
return
super
.
init
(
{
{
code
:
{
code
_sgg
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
allowNull
:
false
,
primaryKey
:
true
,
primaryKey
:
true
,
...
@@ -32,16 +32,16 @@ export class Sgg extends Model {
...
@@ -32,16 +32,16 @@ export class Sgg extends Model {
}
}
static
associate
(
db
)
{
static
associate
(
db
)
{
// 모델이 참조하는 테이블
//
Sgg
모델이 참조하는 테이블
에 대한 외래키 설정
db
.
Sgg
.
belongsTo
(
db
.
Doe
,
{
db
.
Sgg
.
belongsTo
(
db
.
Doe
,
{
foreignKey
:
"
code_do
"
,
foreignKey
:
"
code_do
e
"
,
targetKey
:
"
code
"
,
targetKey
:
"
code
_doe
"
,
});
});
// 모델
이
참조
되
는 테이블
//
Sgg
모델
을
참조
하
는 테이블
에 대한 외래키 설정
db
.
Sgg
.
hasMany
(
db
.
Emd
,
{
db
.
Sgg
.
hasMany
(
db
.
Emd
,
{
foreignKey
:
"
code_sgg
"
,
foreignKey
:
"
code_sgg
"
,
sourceKey
:
"
code
"
,
sourceKey
:
"
code
_sgg
"
,
onDelete
:
"
CASCADE
"
,
onDelete
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
onUpdate
:
"
CASCADE
"
,
});
});
...
...
server/src/models/user.js
View file @
d8cebce9
...
@@ -18,7 +18,7 @@ export class User extends Model {
...
@@ -18,7 +18,7 @@ export class User extends Model {
allowNull
:
false
,
allowNull
:
false
,
primaryKey
:
true
,
primaryKey
:
true
,
},
},
p
w
:
{
p
assword
:
{
type
:
DataTypes
.
STRING
(
20
),
type
:
DataTypes
.
STRING
(
20
),
allowNull
:
false
,
allowNull
:
false
,
},
},
...
@@ -32,13 +32,13 @@ export class User extends Model {
...
@@ -32,13 +32,13 @@ export class User extends Model {
}
}
static
associate
(
db
)
{
static
associate
(
db
)
{
// 모델이 참조하는 테이블
//
User
모델이 참조하는 테이블
에 대한 외래키 설정.
db
.
User
.
belongsTo
(
db
.
Emd
,
{
db
.
User
.
belongsTo
(
db
.
Emd
,
{
foreignKey
:
"
loc_code
"
,
foreignKey
:
"
loc_code
"
,
targetKey
:
"
code
"
,
targetKey
:
"
code
_emd
"
,
});
});
// 모델
이
참조
되
는 테이블
//
User
모델
을
참조
하
는 테이블
에 대한 외래키 설정.
db
.
User
.
hasMany
(
db
.
Weather_in
,
{
db
.
User
.
hasMany
(
db
.
Weather_in
,
{
foreignKey
:
"
host
"
,
foreignKey
:
"
host
"
,
sourveKey
:
"
email
"
,
sourveKey
:
"
email
"
,
...
...
server/src/models/weather_in.js
View file @
d8cebce9
...
@@ -39,7 +39,7 @@ export class Weather_In extends Model {
...
@@ -39,7 +39,7 @@ export class Weather_In extends Model {
}
}
static
associate
(
db
)
{
static
associate
(
db
)
{
// 모델이 참조하는 테이블
//
weather_in
모델이 참조하는 테이블
에 대한 외래키 설정.
db
.
Weather_in
.
belongsTo
(
db
.
User
,
{
db
.
Weather_in
.
belongsTo
(
db
.
User
,
{
foreignKey
:
"
host
"
,
foreignKey
:
"
host
"
,
targetKey
:
"
email
"
,
targetKey
:
"
email
"
,
...
...
server/src/models/weather_out.js
View file @
d8cebce9
...
@@ -10,7 +10,7 @@ export class Weather_Out extends Model {
...
@@ -10,7 +10,7 @@ export class Weather_Out extends Model {
primaryKey
:
true
,
primaryKey
:
true
,
references
:
{
references
:
{
model
:
Emd
,
model
:
Emd
,
key
:
"
code
"
,
key
:
"
code
_emd
"
,
},
},
},
},
collected_at
:
{
collected_at
:
{
...
@@ -43,10 +43,10 @@ export class Weather_Out extends Model {
...
@@ -43,10 +43,10 @@ export class Weather_Out extends Model {
}
}
static
associate
(
db
)
{
static
associate
(
db
)
{
//
모델이 참조하는 테이블
//
weather_out 모델이 참조하는 테이블에 대한 외래키 설정.
db
.
Weather_out
.
belongsTo
(
db
.
Emd
,
{
db
.
Weather_out
.
belongsTo
(
db
.
Emd
,
{
foreignKey
:
"
loc_code
"
,
foreignKey
:
"
loc_code
"
,
targetKey
:
"
code
"
,
targetKey
:
"
code
_emd
"
,
});
});
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment