You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
707 B

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
}