diff --git a/models/tourModel.js b/models/tourModel.js index 60dce7c45f951d89c5eca18b4e35a83ca247edde..11360d99efeb3a0238dc219b26ee1edcf451bbbe 100644 --- a/models/tourModel.js +++ b/models/tourModel.js @@ -1,13 +1,13 @@ -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] );