Search Database (again)

Hi there,
I followed the instructions on this post https://www.wix.com/code/home/forum/wix-tips-and-updates/how-to-create-a-search-for-your-database
but I got stuck in the first step (of the video) where Yoav tests the first section of the code. It doesn’t work at all (probably for some basic mistake).
Need help to overcome this…

Thank you in advance!
Bruno

import wixData from ‘wix-data’;

export function iName_keyPress(event, $w) {
filter($w(‘iName’).value);
}
function filter(Nome) {
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘Nome Texto’, Nome));
}

Make sure you use the Field Key and not the Field Name as shown in this example screenshot:


You want this (check your database for the exact field key):
$w(’ #dataset1 ').setFilter(wixData.filter().contains(‘nomeTexto’, Nome));
And not this:
$w(’ #dataset1 ').setFilter(wixData.filter().contains(‘Nome Texto’, Nome));

Note that the Field Key starts with a small letter and not a capital letter.

Hi Yisrael,
Thank you for your help. Actually the code was has you said, but I copy it while doing some tests. I tried again and unfortunately it didn’t work. Could you help me detect the problem with this? I have a big team to display and such tool would be so useful.

Best,
Bruno

Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor.

Is it this one? https://editor.wix.com/html/editor/web/renderer/edit/9d07094a-3b34-4626-859f-5a7af0e76686?metaSiteId=0dd103e0-7abc-4f8a-bc7c-7dc59185c4a9&editorSessionId=aa2537d3-2344-4a94-8244-21b0f77b43fd&referralInfo=dashboard

@brunovasconcelos On what page are you doing the database search?

@yisrael-wix its on “People”

@brunovasconcelos I can’t find this page anywhere on your site.

@yisrael-wix https://www.dinamiacet.iscte-iul.pt/people
Print screen of the menu in the BO

@brunovasconcelos

The main problem you have is that the input component ID is missing the hashtag.

You want this:
filter($w(‘#iName’).value);

In addition, you should include a timeout for the input control. For more information on this, see the post Give the TextInput onKeyPress Function some time . Your keypress function should look something like this:

export function iName_keyPress(event, $w) {
    setTimeout(() => {
        filter($w('#iName').value);
    }, 10); // 10 milliseconds works for me
}

I hope this helps. Good luck,

Yisrael

@yisrael-wix thank you so much! It works!