Database search / export to repeater

Hi mates, I need some help! :slight_smile:

I would like to use a very little code to search a database by using a ‘user text field’ (“input”) in combination with a ‘search button’ (“iconButton1_click”) and an export of the results to a ‘repeater’ (“repeater1”).

Database (“MGL-III”) and repeater are working fine on the site but ‘the search’-code doesn´t. Nothing happens while using text field and button. Can you help?

This is the little code I am “using” right now:

import wixData from ‘wix-data’;
export function iconButton1_click(event) {
function search() {
.contains(‘kurztext’, $w(“#input”).value)
.or(wixData.query(‘MGL-III’).eq(‘title’, $w(“#input”).value))
.then(res => {
$w(‘#repeater1’).data = res.items;
Thank you guys very much in advance!
Nice regards from the Baltic Sea-area :slight_smile:

I have used similar on a site for searching with a button, although my results were shown in a table and not in a repeater.

import wixData from 'wix-data'

 $w.onReady(function () {

    $w('#searchButton').onClick(function () {

            .contains("songName", $w("#searchInput").value)
                .contains("artistName", $w("#searchInput").value))
             .then((results) => {
 let resultsItems = results.items;

                  $w('#resultsTable').rows = resultsItems;

Where I have the onClick event handler line, I had to add the onClick from the properties panel for that button element.

So, where you have your own onClick event handler on your icon button, you will need to make sure that you also have the onClick event function handler added to the button through the properties panel.

You can see more about it here.

Plus, have a look sat this example from Vorbly as it is a great little example for a search using repeaters.

Also, note that the eq function from Wix Data Query is case sensitive too.
Matching strings with eq() is case sensitive, so “text” is not equal to “Text”.

So if people search for your name for example, if they search for Andre they will find your name, whereas if they search for andre they won’t.

Hi GOS, thank you very much for your support!!! I will give it a try and report back to you soon… Nice regards, André