const { getDatabase } = require('../config/database');

class Role {
    /**
     * Get all roles
     */
    static getAll() {
        const db = getDatabase();
        const stmt = db.prepare('SELECT * FROM roles ORDER BY id');
        return stmt.all();
    }

    /**
     * Get role by ID
     */
    static getById(id) {
        const db = getDatabase();
        const stmt = db.prepare('SELECT * FROM roles WHERE id = ?');
        return stmt.get(id);
    }

    /**
     * Get role by name
     */
    static getByName(name) {
        const db = getDatabase();
        const stmt = db.prepare('SELECT * FROM roles WHERE name = ?');
        return stmt.get(name);
    }
}

module.exports = Role;
