I have a simple page where I need to validate an email ID that user enters against my database. I created a simple collection called “DLPRegisteredStudents” where there are fields such as EMail_ID, Date_Registered, Date_Ended, and Active_Flag. I created a page with just one input field accepting Email ID and a button to Validate. For some reason the WixData.query function is not working for me. Here is the code: Can someone help me??
export function button1_click_1(event) {
//Add your code for this event here:
console.log(“Came Here”)
wixData.query(“DLPRegisteredStudents”)
.eq(“Email_ID”,$w(‘#emailEntered’))
.eq(“Acive_Flag”, “Yes”)
.find()
.count()
.then((num) => {
let numOfEmails = num;
})
.then((results) => {
if (results.items.length > 0) {
let items = results.items;
let firstItem = items[0];
console.log(results.items);
$w(“#DateRegistered”).text = “Date Registered: " & results.Date_Registered;
$w(”#DateEnded").text = "Date Ended: " & results.Date_Ended;
//display the Registered Date and End Date values read…
$w(‘#DateRegistered’).isVisible;
$w(‘#DateEnded’).isVisible;
} else {
$w("#emailEntered").value = "Invalid or Inactive Email ID. Please try again"
// $w(‘#emailNotFoundMsg’).isVisible
// handle case where no matching items found
}
})
. catch ((error) => {
let errorMsg = error.message;
let code = error.code;
});
}