Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MelonDeployFinal2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160117
MelonDeployFinal2
Commits
2a5f724b
Commit
2a5f724b
authored
1 month ago
by
65160117
Browse files
Options
Downloads
Patches
Plain Diff
Edit database.js
parent
726c3bc5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
config/database.js
+12
-27
12 additions, 27 deletions
config/database.js
with
12 additions
and
27 deletions
config/database.js
+
12
−
27
View file @
2a5f724b
require
(
'
dotenv
'
).
config
();
const
mysql
=
require
(
'
mysql2
'
);
// สร้าง connection pool
const
pool
=
mysql
.
createPool
({
host
:
process
.
env
.
DB_HOST
,
user
:
process
.
env
.
DB_USER
,
password
:
process
.
env
.
DB_PASSWORD
,
database
:
process
.
env
.
DB_NAME
,
port
:
process
.
env
.
DB_PORT
,
waitForConnections
:
true
,
connectionLimit
:
10
,
queueLimit
:
0
});
// ทดสอบการเชื่อมต่อฐานข้อมูล
pool
.
getConnection
((
err
,
connection
)
=>
{
if
(
err
)
{
console
.
error
(
'
Error connecting to the database:
'
,
err
);
return
;
const
{
Sequelize
}
=
require
(
'
sequelize
'
);
const
sequelize
=
new
Sequelize
(
process
.
env
.
DB_NAME
,
process
.
env
.
DB_USER
,
process
.
env
.
DB_PASSWORD
,
{
host
:
process
.
env
.
DB_HOST
,
dialect
:
'
mysql
'
,
logging
:
false
,
}
console
.
log
(
"
Successfully connected to the database.
"
);
connection
.
release
();
});
// Export pool promise เพื่อใช้ async/await
const
promisePool
=
pool
.
promise
();
);
module
.
exports
=
promisePool
;
\ No newline at end of file
module
.
exports
=
sequelize
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment