server initial commit
This commit is contained in:
23
server/models/users.js
Normal file
23
server/models/users.js
Normal file
@ -0,0 +1,23 @@
|
||||
import db from "./db.js";
|
||||
/** @typedef User
|
||||
* @property {number} id - The unique identifier for the user.
|
||||
* @property {string} username - The username of the user.
|
||||
* @property {string} password - The hashed password of the user.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetches all users from the database.
|
||||
* @return {Promise<User[]>}
|
||||
*/
|
||||
const getAllUsers = async () => {
|
||||
try {
|
||||
return await db.query('SELECT * FROM users').then((users) => users);
|
||||
} catch (error) {
|
||||
console.error('Error fetching users:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
getAllUsers
|
||||
}
|
||||
Reference in New Issue
Block a user