Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit e8aad672 authored by 65160394's avatar 65160394
Browse files

Project Round 2

parent bfb035e2
Branches
No related tags found
No related merge requests found
const db = require('../config/database');
const pool = require('../config/database');
const bcrypt = require('bcryptjs');
class Tour {
static async getAllTours() {
const [rows] = await db.query('SELECT * FROM tours');
const [rows] = await pool.query('SELECT * FROM tours');
return rows;
}
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];
}
}
......@@ -15,7 +15,7 @@ class Tour {
class User {
static async findOne(email) {
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;
} catch (err) {
throw err;
......@@ -25,7 +25,7 @@ class User {
static async create(name, email, password) {
try {
const hashedPassword = await bcrypt.hash(password, 10);
const [result] = await db.query(
const [result] = await pool.query(
'INSERT INTO users (name, email, password) VALUES (?, ?, ?)',
[name, email, hashedPassword]
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment