I have implemented a search against a database of magazines. Each magazine may have up to four articles of interest. I am trying to retrieve all magazines with the word or phrase entered into a search input box. It ONLY works against the first field. What Am I Missing here?
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
$w.onReady(function () {
//TODO: write your page related code here…
});
Thanks Tal,
I already looked at that video but I don’t need the filter. Then I found Nayeli tutorial which was way more easier. https://youtu.be/ZdIB0Q7WXP4
After I got it working I modified the .contains to use an OR to see if the search value was contained in the other three database fields.
I just looked at the other thread. Should I be using multiple if statements?
Scroll up… it is in my initial post. HERE is is again:
import wixData from ‘wix-data’;
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
$w.onReady(function () {
//TODO: write your page related code here…
});
export function searchButton_onclick() {
wixData.query(‘CVOA-Magazines’)
.contains(‘article1’ || ‘article2’ || ‘article3’ || ‘article4’,$w(’ #input1 ‘).value)
.find()
.then(res=>{
$w(’ #table1 ').rows = res.items;
});
}
Following her original code for the contains was:
.contains(‘article1’,$w(’ #input1 ').value)
And that works as expected. I added the OR condition to check the other fields. It only returns items with the match in ‘article1’.
I’m developing a site with a different topic but similar data structure.
Did you solve your problem with multiple fields search? I’m desperate to make it run.
This code works perfectly! but I am trying to perfect this. If you write more than one word it doesn’t show any results unless the string be entered exactly as the data phrase is wrote, so I would like to make this can combine words with no matter the order are entered and so find combinations… EG