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.
 
 
 

26 lines
691 B

const { database } = require('../database')
const getStatusMention = (menstionText) => {
const query = database.prepare('SELECT * FROM status')
let response = query.all()
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
}