Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

67
Visualizações
Javascript return true if the record is exist on the database

After clicking submit button, it will check if the record is exist on the database, if exist it will return true, the problem here is I dont know how to return true

//button click
if(_data.hasExistingEvent(_data.getFormData())){ ==> this will check if true or false
   ///if true
}else{

}

I don't have problem on my query but I just want that if the form exist on the database it will return true and if not it will return false

....


hasExistingEvent: (data) => {
    var {  assignedTo, startDate } = data
    var s = moment(startDate, 'DD/MM/YYYY hh:mm A').toDate()
    var newDate = moment(s).format("YYYY-MM-DD HH:mm")
    return  new Promise((resolve, reject) => {
        ....("SELECT assignedTo, startDate FROM Event WHERE assignedTo LIKE '%" + assignedTo + "%' AND startDate BETWEEN '" + moment(newDate).startOf(`day`).format() + "' AND '" + moment(newDate).endOf(`day`).format() + "'", 100, function(a){
            var valid = false;
            return valid = resolve(a.length == 0) // here
        })
    })
},
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Here you are returning a variable assignation with the = operator. Returning valid = resolve(a.length == 0) does not make any sense since you are assigning the result of resolve(a.length == 0) to the variable valid. If you want to check for equality, use === or ==. The first possibility here is to do:

  var valid = false;
  return valid === resolve(a.length == 0)

Or, for a more concise code, just get rid of the valid variable and return:

return !resolve(a.length ==0)
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda