Search bar to search through loads of databases and display results in a table

Hello,

I’m very near releasing my website, but I’m still blocked on this piece of code to search through load of databases and display all results in a table.

I have two main problems :

  • The Field name “Set name” is a referenced field from another general database and the information never shows in the table colomns.
  • The code works to search into 2 databases, but when I try to add a third one I only get results for 2 of them (the first one and last one)

I’m planning to add more and more databases to the search code, I looking for an easy to learn way to do that.

For example I would need to add the following collection IDs : amada2001, amadasuperdx1998, dxgold, retsudenhyperstickercollection2, amada3, amada4, superdx2000, toppusealgumjohto, worldhobbyfairpart1, worldhobbyfairpart2, worldhobbyfairpart3

And many more once the databases are created.

Each database represents a sticker set. The users search for a pokemon name and they get the list of stickers that exist for that one Pokemon.

Here’s my code below :

import wixData from 'wix-data'  

$w.onReady(function () { 
 $w("#resultsTable").columns = [{

          "id": "col1",

          "dataPath": "stickernumber",

          "label": "Sticker Number",

          "width": 100,

          "visible": true,

          "type": "number"

        } ,

        {

          "id": "col2",

          "dataPath": "title",

          "label": "Name",

          "width": 100,

          "visible": true,

          "type": "string"

        },

        {

          "id": "col3",

          "dataPath": "Stickersetlist.title",

          "label": "Set Name",

          "width": 100,

          "visible": true,

          "type": "string"

        },
 {

          "id": "col4",

          "dataPath": "manu_year",

          "label": "Year",

          "width": 80,

          "visible": true,

          "type": "Number",

        } ,
        {

          "id": "col5",

          "dataPath": "type",

          "label": "Type",

          "width": 100,

          "visible": true,

          "type": "string",

        } ,
        {

          "id": "col6",

          "dataPath": "image",

          "label": "Image",

          "width": 300,

          "visible": true,

          "type": "image",

        },
];
$w('#search').onClick(() => { 
const queries = ["Toppu1997", "ToppuSealGum1", "RetsudenHyperStickerCollection1"].map(collection => wixData.query(collection)             
   .contains("title", $w("#searchinput").value)             
   .or(wixData.query(collection)                 
   .contains("featuring_pkmn", $w("#searchinput").value)));

   Promise.all(queries.map(q => q.find()))

  .then(r => {
    $w("#resultsTable").rows = r[0].items.concat(r[2].items);

  })
})
})

I have a little to no experience with wix coding unfortunately, I spent a lot of time trying to figure this code out.

Thanks in advance to anyone who can help me out