Searching date fields in database without connecting any data set.

When my search results go to the results page, the results seems to take a long time to populate, with experience of other pages with datasets removed any pulling the data straight from database it seems to have drastically improved loading times.

I have been trying to implement this on the search results page, but have been struggling with the multiple date fields within the database. I can get one date to fill i.e. ‘dateOne’ but as soon as I try and get 'dateOne '‘dateTwo’ etc i can’t get them to work…

function fillRepeater() {
 let startDate = $w('#Coursestartdate').value
        wixData.query("Courses")
       .contains("coursesCategory", $w('#coursenamedropdown').value)
       .contains("region", $w('#regionDropdown').value) 
       .contains("pageTitle", $w('#dropdownDifficulty').value)
       .contains("duration", $w('#durationdropdown').value)
       .contains("dates", $w('#CourseAccomodationDropdown').value)
        .eq('dateOne', startDate).or('dateTwo', startDate).or('datethree', startDate)
        .find()
        .then((results) => {
            $w('#searchrepeater').data = results.items;
            $w('#searchrepeater').forEachItem(($w, itemData, index) => {
                $w("#button21").link = "/Courses/"+encodeURI(itemData.coursesCategory)+"/"+encodeURI(itemData.title);
                $w("#button21").label = itemData.title;
                $w("#searchimage").src = itemData.image;
                $w("#searchimage").link= "/Courses/"+encodeURI(itemData.coursesCategory)+"/"+encodeURI(itemData.title);
$w('#searchrepeater').data = results.items;
            }
            );
        });
 
}

Many thank in advance!

Look here, I think this answers your question: https://wixshow.wixanswers.com/en/article/how-to-make-a-query-using-or-in-wix-code

Thank you Andreas! Works great :slight_smile:

The code if it helps anyone else

function fillRepeater() {
 let startDate = $w('#Coursestartdate').value
        wixData.query("Courses")
       .contains("coursesCategory", $w('#coursenamedropdown').value)
       .contains("region", $w('#regionDropdown').value) 
       .contains("pageTitle", $w('#dropdownDifficulty').value)
       .contains("duration", $w('#durationdropdown').value)
       .contains("dates", $w('#CourseAccomodationDropdown').value)
        .eq('dateOne', startDate)
        .or(
             wixData.query("Courses")
        .eq("dateTwo", startDate))
        .or(
             wixData.query("Courses")
        .eq("dateThree", startDate))
        .find()
        .then((results) => {
            $w('#searchrepeater').data = results.items;
            $w('#searchrepeater').forEachItem(($w, itemData, index) => {
                $w("#button21").link = "/Courses/"+encodeURI(itemData.coursesCategory)+"/"+encodeURI(itemData.title);
                $w("#button21").label = itemData.title;
                $w("#searchimage").src = itemData.image;
                $w("#searchimage").link= "/Courses/"+encodeURI(itemData.coursesCategory)+"/"+encodeURI(itemData.title);
                $w('#searchrepeater').data = results.items;
            }
            );
        });
 
}

Hey Andreas, I have a new problem… if the $w(‘#Coursestartdate’) value = null then the search displays no results as the query is searching for a date, would you be able to help me with a solution?

Thank you for your help my friend