Show results in a repeater/container after a query

Hello guys,

i am working on something quite big. I am trying to build a communication platform for small and medium enterprises and if this works out it will be a part of my bachelor thesis.

A part of my site will include some sort of search function, where you can search for a company via different variables (Title, category, city).

I created a query function, in which i use an input box and an event button to query my database. I want the query to react on a repeater and show the fitting results from the database. The repeater is collapsed when the site is loaded so i thought it would be wise to use the “expand”-function.

I saw a similiar code working absolutely fine but mine doesnt even start querying i think.

I share my code with you:

//

import wixData from ‘wix-data’;

export function button2_click(event, $w) {

wixData.query(“buisnessdatabase”)
.eq(“Title”,$w(“#input1”).value)
.or(wixData.query(“buisnessdatabase”) .eq(“city”,$w(“#input1”).value))
.or(wixData.query(“buisnessdatabase”) .eq(“category”,$w(“#input1”).value))
.ascending(“city”)
.limit()
.find()
.then( () =>{
$w(“#repeater1”).expand(“#container1”) ;
} );

}

//

I hope that this makes any sense at all.
I am looking forward to your replies!

Greetings,
Dawd

1 Like

How about trying to filter the dataset instead?

Here … let me show you one of my clients sites … all I did was add a bit of code to his existing site …

(View on desktop only)

Hi,
You can check out the first step of the example I mentioned here .

Best,
Tal.

Thank you both for the input,

Nayeli, i experimented a bit with the filter function but my skills were a bit…rookie, so to say. So progress was very slow haha. Any recommendations for the query-function? I would really prefer to work with that function.

Tal, at which point i have to include or “mention” the input boxes within the function?

Greetings

On the second step, you can get the value of the text input and filter the irrelevant results using the filter JS function. Moreover, on the third step, you filter the relevant results in case the user changes the input.