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
9185af02
Commit
9185af02
authored
2 months ago
by
65160117
Browse files
Options
Downloads
Patches
Plain Diff
Edit database.js
parent
327294d8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
config/database.js
+27
-12
27 additions, 12 deletions
config/database.js
with
27 additions
and
12 deletions
config/database.js
+
27
−
12
View file @
9185af02
const
{
Sequelize
}
=
require
(
'
sequelize
'
);
require
(
'
dotenv
'
).
config
();
const
mysql
=
require
(
'
mysql2
'
);
const
sequelize
=
new
Sequelize
(
process
.
env
.
DB_NAME
,
process
.
env
.
DB_USER
,
process
.
env
.
DB_PASSWORD
,
{
// สร้าง connection pool
const
pool
=
mysql
.
createPool
({
host
:
process
.
env
.
DB_HOST
,
dialect
:
'
mysql
'
,
logging
:
false
,
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
;
}
);
console
.
log
(
"
Successfully connected to the database.
"
);
connection
.
release
();
});
// Export pool promise เพื่อใช้ async/await
const
promisePool
=
pool
.
promise
();
module
.
exports
=
sequelize
;
\ No newline at end of file
module
.
exports
=
promisePool
;
\ 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