Seguinte eu tenho duas tabelas uma de students e outra de users e estou tentando fazer uma chamada de login simples, verificando o email e o password do user através da chave estrangeira entre students e user. Porém só esta me retornando vazio, alguem poderia me ajudar?
async create(request, response) {
const { email, password } = request.body;
const type = 's';
const student = await connection('users as u')
.innerJoin('students as s')
.where('s.email', email)
.andWhere('s.id', 'u.student_id')
.andWhere('u.password', password)
.andWhere('u.type', type)
.select('*')
console.log(student);
if(!student) {
return response.status(400).json({ error: 'No Student found with this Email' });
}
return response.json(null);
}