Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project
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
65160394
Project
Commits
e8aad672
Commit
e8aad672
authored
3 months ago
by
65160394
Browse files
Options
Downloads
Patches
Plain Diff
Project Round 2
parent
bfb035e2
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
models/tourModel.js
+5
-5
5 additions, 5 deletions
models/tourModel.js
with
5 additions
and
5 deletions
models/tourModel.js
+
5
−
5
View file @
e8aad672
const
db
=
require
(
'
../config/database
'
);
const
pool
=
require
(
'
../config/database
'
);
const
bcrypt
=
require
(
'
bcryptjs
'
);
const
bcrypt
=
require
(
'
bcryptjs
'
);
class
Tour
{
class
Tour
{
static
async
getAllTours
()
{
static
async
getAllTours
()
{
const
[
rows
]
=
await
db
.
query
(
'
SELECT * FROM tours
'
);
const
[
rows
]
=
await
pool
.
query
(
'
SELECT * FROM tours
'
);
return
rows
;
return
rows
;
}
}
static
async
getTourById
(
id
)
{
static
async
getTourById
(
id
)
{
const
[
rows
]
=
await
db
.
query
(
'
SELECT * FROM tours WHERE id = ?
'
,
[
id
]);
const
[
rows
]
=
await
pool
.
query
(
'
SELECT * FROM tours WHERE id = ?
'
,
[
id
]);
return
rows
[
0
];
return
rows
[
0
];
}
}
}
}
...
@@ -15,7 +15,7 @@ class Tour {
...
@@ -15,7 +15,7 @@ class Tour {
class
User
{
class
User
{
static
async
findOne
(
email
)
{
static
async
findOne
(
email
)
{
try
{
try
{
const
[
rows
]
=
await
db
.
query
(
'
SELECT * FROM users WHERE email = ?
'
,
[
email
]);
const
[
rows
]
=
await
pool
.
query
(
'
SELECT * FROM users WHERE email = ?
'
,
[
email
]);
return
rows
.
length
>
0
?
rows
[
0
]
:
null
;
return
rows
.
length
>
0
?
rows
[
0
]
:
null
;
}
catch
(
err
)
{
}
catch
(
err
)
{
throw
err
;
throw
err
;
...
@@ -25,7 +25,7 @@ class User {
...
@@ -25,7 +25,7 @@ class User {
static
async
create
(
name
,
email
,
password
)
{
static
async
create
(
name
,
email
,
password
)
{
try
{
try
{
const
hashedPassword
=
await
bcrypt
.
hash
(
password
,
10
);
const
hashedPassword
=
await
bcrypt
.
hash
(
password
,
10
);
const
[
result
]
=
await
db
.
query
(
const
[
result
]
=
await
pool
.
query
(
'
INSERT INTO users (name, email, password) VALUES (?, ?, ?)
'
,
'
INSERT INTO users (name, email, password) VALUES (?, ?, ?)
'
,
[
name
,
email
,
hashedPassword
]
[
name
,
email
,
hashedPassword
]
);
);
...
...
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