C-university/database/function/Helper.js
2025-07-17 14:52:04 +02:00

28 lines
707 B
JavaScript

const { pool } = require('../database')
const getStatusMention = async (menstionText) => {
const query = 'SELECT * FROM status'
let [rows] = await pool.query(query)
let response = rows
let statutCode
for (let index = 0; index < response.length; index++) {
let nom = response[index].nom
let nomLower = nom.toLowerCase() // Correct method
let find1 = menstionText.slice(0, 1)
let find2 = menstionText.slice(0, 3)
if (nomLower.slice(0, 1) == find1.toLowerCase()) {
statutCode = response[index].id
} else if (nomLower.slice(0, 3) == find2.toLowerCase()) {
statutCode = response[index].id
}
}
return statutCode
}
module.exports = {
getStatusMention
}