function foo(){ // conexion // query if (/** query exitosa **/) { return true; } else { return false; }}if (foo()) { // function terminada con exito}