0

I am using sequelize in my project. I am using the following format to get the results. But each row in the result is returned as textRow. Is it ok if I can directly access using the index or Do I need to convert textrow? Need your suggestions.

const testQuery = await sequelizeConn.query(`select * from users where user_name = '${reqParams.userName}'`, {
         raw: true
      })
if(testQuery && testQuery.length > 0 && testQuery[0].length > 0){
}
user846445
  • 221
  • 1
  • 3
  • 14

1 Answers1

1

You need to remove raw:true because already it's working like raw query and try promise instead of async/await.

    
         sequelize.query(`select * from users where user_name = ${reqParams.userName}`, {model: users})
          .then(function(result) {
         
            if(result && result.length > 0 && result[0].length > 0){
    console.log(result);
    }
            
          }).catch(error=>{
                  console.log(error);
});
    
    
aum trivedi
  • 129
  • 4