Toggle navigation
Toggle navigation
This project
Loading...
Sign in
방승일
/
mamuri-bot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
윤준석
2022-05-24 01:13:51 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
870a93aecfef112321c48a1200b31ccca5b989ed
870a93ae
1 parent
b122fb12
ADD: node.js sequelize orm install and initialization
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
server/config/config.json
server/models/index.js
server/config/config.json
0 → 100644
View file @
870a93a
{
"development"
:
{
"username"
:
"root"
,
"password"
:
"mamuri"
,
"database"
:
"mamuri_db"
,
"host"
:
"127.0.0.1"
,
"dialect"
:
"mysql"
},
"test"
:
{
"username"
:
"root"
,
"password"
:
null
,
"database"
:
"database_test"
,
"host"
:
"127.0.0.1"
,
"dialect"
:
"mysql"
},
"production"
:
{
"username"
:
"root"
,
"password"
:
null
,
"database"
:
"database_production"
,
"host"
:
"127.0.0.1"
,
"dialect"
:
"mysql"
}
}
server/models/index.js
0 → 100644
View file @
870a93a
'use strict'
;
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
Sequelize
=
require
(
'sequelize'
);
const
basename
=
path
.
basename
(
__filename
);
const
env
=
process
.
env
.
NODE_ENV
||
'development'
;
const
config
=
require
(
__dirname
+
'/../config/config.json'
)[
env
];
const
db
=
{};
let
sequelize
;
if
(
config
.
use_env_variable
)
{
sequelize
=
new
Sequelize
(
process
.
env
[
config
.
use_env_variable
],
config
);
}
else
{
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
config
);
}
fs
.
readdirSync
(
__dirname
)
.
filter
(
file
=>
{
return
(
file
.
indexOf
(
'.'
)
!==
0
)
&&
(
file
!==
basename
)
&&
(
file
.
slice
(
-
3
)
===
'.js'
);
})
.
forEach
(
file
=>
{
const
model
=
require
(
path
.
join
(
__dirname
,
file
))(
sequelize
,
Sequelize
.
DataTypes
);
db
[
model
.
name
]
=
model
;
});
Object
.
keys
(
db
).
forEach
(
modelName
=>
{
if
(
db
[
modelName
].
associate
)
{
db
[
modelName
].
associate
(
db
);
}
});
db
.
sequelize
=
sequelize
;
db
.
Sequelize
=
Sequelize
;
module
.
exports
=
db
;
Please
register
or
login
to post a comment