Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

66
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda