I have several databases of the same structure and format.
For example;
Germany collection
France Collection
Italy Collection.
Is it possible to make the word entered in a single search bar as a common search page for all? how can I do it. Can you send a sample code. This will be very useful to me.
Since the databases are all in the same format, it should be easy to search, all I want is to search the same word with a single search bar and show the results in one repeater.
Multiple databases search and merge results on the same page? How to do it. Sample code request - Databases have the same columns.
There may be better, faster ways, but right now that’s what comes to mind. Hope it works for you.
export async function input1_change(event) {
let data1 = await wixData.query("Germany")
.eq("city", $w('#input1').value)
.find();
let data2= data1.items;
let data3 = await wixData.query("France")
.eq("city", $w('#input1').value)
.find();
let data4= data3.items;
let data5 = [...data2, ...data4];
$w('#repeater1').data = data5;
}
//This is how you define the data
export function repeater1_itemReady($item, itemData, index) {
$item("#textcity").text = itemData.city;
// It defines only one field called a city.
//If you have any other fields or pictures you will add here accordingly.
}
Hi; firstly many thanks for the answer
Of course I will share the positive result. But I have one last question. How do I make the display link in the repeater. Do I need to link it to a collection?
So finally I have a question. In order for the results of the data to come quickly, would it be possible to have 10 pieces of 10 pieces piece by piece? If so, how to add the sample code you send.
I think you’re wrong here, it’s different than what I suggested.
let data4 = [data1, data2, data3];
It should be like this:
let data4 = data3.items;
let data5 = [... data2, ... data4];
let data4 = data3.items;
let data5 = [... data2, ... data4];
Note that the search will only take place after you finish entering the input field, this is a function that works after the information is finished
You can use the search time in the function
$ w (“# myElement”). onInput ((event) => {
let newValue = event.target.value; "
});
But I would not recommend you because it will slow down your writing, because it executes complex code, it is better that you add a button that presses the filter. Or you can do it by checking ‘Enter’