Hi, I have question regarding search with multiple fields on my project: I have a collection with fullName, hour of credit hour, university and i want users to be able to search by name and also search by the combination of hour of credit hour and university. The part of search by name i just use simple search function shown at code i provided below but the combination search i can’t figure out how. I try wixData.query as above example shown but the repeater i used to display result cannot show the exact items. code sample:
import wixData from ‘wix-data’;
$w.onReady(function () {
$w(‘#repeater1’).hide();
wixData.query(“CSguru”)
.find()
.then((results) => {
let sum = 0;
results.items.forEach((item) => {
sum += 1;
});
let sumString = sum.toString();
$w(“#text18”).text = sumString; // display sum
});
$w('#repeater1').onItemReady(($w, itemData, index) => {
$w(`#text21`).text = itemData.fullName;
$w('#text22').text = itemData.email;
$w('#image1').src = itemData.profilePhoto;
$w(`#text23`).text = itemData.about;
$w(`#text25`).text = itemData.hourOfTeaching.toString();
});
});
export function iconButton1_click(event, $w) {
//Add your code for this event here:
let searchValue = $w(‘#input1’).value;
let csguruCredit = $w(‘#input2’).value;
$w(‘#repeater1’).show();
wixData.query(‘CSguru’)
.contains(“fullName”, searchValue)
.or(wixData.query().contains(“hourOfTeaching”, searchValue))
.find()
.then(res => {
$w(‘#repeater1’).data = res.items;
})
}
export function input1_keyPress(event, $w) {
//Add your code for this event here:
if (event.key === “Enter”) {
let searchValue = $w(‘#input1’).value;
$w(‘#repeater1’).show();
wixData.query(‘CSguru’)
.contains(“fullName”, searchValue)
.find()
.then(res => {
$w(‘#repeater1’).data = res.items;
})
}
}
Please guide me…