Need Help With Database Searching

Hello,
So I’ve been trying to make a searchbar that searches through multiple databases, and I’m so close to getting it to work. I’ve gotten it to work with one database easily, but I cant make it work with multiple.

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixwindow from 'wix-window';
import wixlocation from 'wix-location';
import {session} from 'wix-storage';
import wixdata from 'wix-data';
import wixbookings from 'wix-bookings';
import {memory} from'wix-storage'

$w.onReady(function () {
 var platform = wixwindow.formFactor;
 if (platform === 'Mobile') {

        $w('#text16').expand()
    } else if (platform === 'Tablet') {
 
    } else if (platform === 'Desktop') {
        $w('#text16').collapse()
    }
    session.removeItem('noresults')
    session.removeItem('searchResults')
});

export function queryPhones (search) {
        wixdata.query('Devices-Phones')
        .contains('title', search)
        .find()
        .then( (results) => {
 return results.items;
        })
}

export function queryTablets (search) {
    wixdata.query('Devices-Tablets')
        .contains('title', search)
        .find()
        .then( (results) => {
 return results.items;
        })
}

export function queryLaptops (search) {
    wixdata.query('Devices-Laptops')
        .contains('title', search)
        .find()
        .then( (results) => {
 return results.items;
        })
}

export function queryiPhones (search) {
    wixdata.query('Phones-iPhones')
        .contains('title', search)
        .find()
        .then( (results) => {
 return results.items;
        })
}

export function searchquery () {
    session.removeItem('searchResults')
 var search = $w('#input1').value;
    console.info(search)
 if (search === null) {
 var defColor = $w('#input1').style.borderColor
 var defColor2 = $w('#box4').style.backgroundColor
        $w('#input1').style.borderColor = 'rgb(200,0,0)'
        $w('#box4').style.backgroundColor = 'rgb(200,0,0)'
        setTimeout( function() {
                $w('#input1').style.borderColor = defColor
                $w('#box4').style.backgroundColor = defColor2
        }, 2000)
    } else {
 var phonesearchResults = queryPhones(search)
 var searchResults = phonesearchResults.concat()
 if (searchResults.length === 0) {
            wixlocation.to('/noresults')
            session.setItem('noresults', 'yes')
        } else {
 var searchString = JSON.stringify(searchResults)
            session.setItem('searcchResults', searchString) 
            wixlocation.to('/search-results')
        }
    }
}

export function input1_keyPress(event) {
 if (event.key === 'Enter') {
        searchquery()
    }
}

export function input1_mouseIn(event) {
    $w('#box4').style.backgroundColor = '#394A7B'
}

export function input1_mouseOut(event) {
    $w('#box4').style.backgroundColor = '#566FB8'
}

export function input1_focus(event) {
    $w('#box4').style.backgroundColor = '#1E3685'
}

export function input1_blur(event) {
    $w('#box4').style.backgroundColor =  '#566FB8'
}

export function vectorImage3_click_1(event) {
    searchquery()
}

The problem I’m having is that my query functions are not returning arrays, so I cant combine them into a single array using the concat command. I didn’t finish the concat command because it would’t have worked.
It’s important to note that the searchbar and my results are on different pages. I’m displaying my results using a repeater, which worked with one database.
Here is the code for the search results page.

// For full API documentation, including code examples, visit https://wix.to/94BuAAs

import wixdata from 'wix-data'
import {session} from 'wix-storage'
import wixlocation from 'wix-location'

$w.onReady(function () {
 var search = session.getItem('searchResults')
 var searchResults = JSON.parse()    
    console.dir(searchResults)
    $w('#repeater1').data = searchResults
    $w('#repeater1').forEachItem( ($item, itemmdata, index) => {
        $item.id = searchResults._id
        $item('#text13').text = itemmdata.title;
        $item('#text11').text = itemmdata.description;
        $item('#text15').text = itemmdata.deviceForm;
        $item('#image2').src = itemmdata.repairability;
        $item('#gallery1').src = itemmdata.image;
    })
});

export function button2_click(event) {
        session.removeItem('title')
 let $item = $w.at(event.context)
 let device = $item("#text15").text
        session.setItem('title',device)
        wixlocation.to('/repairform');
}

I hope someone can help me with this, thank you.

You can do simple code like this

wixData.query("YourDataset")
.contains("fieldkey", $w("#searchInput").value)
.or(wixData.query("YourDataset")
.contains("fieldkey", $w("#searchInput").value))
.find()
.then((results) => {
let resultsItems = results.items;
console.log(resultsItems);

Or have a look here at multiple dataset referencing.
CMS: About Connecting Multiple Database Collections | Help Center | Wix.com.
CMS: Displaying Content from Multiple Database Collections Using Datasets | Help Center | Wix.com

Also, check out this previous forum post too.
https://www.wix.com/corvid/forum/community-discussion/help-with-querying-referenced-fields%3Fpage%3D1%26dl%3D5c33c1c95516de01d29e8d88%252f5c17f9493aeebe016fec021c%252f1
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-wix-data-multiple-references

While I appreciate you giving me a solution, I would rather you tell me what’s wrong with my code. I will try your suggestion, but I don’t want to delete all my code if I don’t have to.

Here’s the new code I made and it’s still not working. The console error I’m getting is 'Invalid .or parameter"

export function searchquery () {
    session.removeItem('searchResults')
 var search = $w('#input1').value;
    console.info(search)
 if (search === null) {
 var defColor = $w('#input1').style.borderColor
 var defColor2 = $w('#box4').style.backgroundColor
        $w('#input1').style.borderColor = 'rgb(200,0,0)'
        $w('#box4').style.backgroundColor = 'rgb(200,0,0)'
        setTimeout( function() {
                $w('#input1').style.borderColor = defColor
                $w('#box4').style.backgroundColor = defColor2
        }, 2000)
    } else {
        wixdata.query('Devices-Phones')
            .contains('title', search)
            .not(
                wixdata.query('Devices-Phones')
                    .contains('title', 'Apple Phones')
            )
            .or(
                wixdata.query('Devices-Tablets')
                    .contains('title', search)
            )
            .or(
                wixdata.query('Devices-Laptops')
                    .contains('title', search)
            )
            .or(
                wixdata.query('Phones-iPhones')
                    .contains('title', search)
            )
            .find()
            .then( (results) => {
 if (results.items.length > 0) {
                    session.setItem('searchResults', JSON.stringify(results.items))
                    wixlocation.to('/search-results')
                } else {
                    session.setItem('noresults', 'yes')
                    wixlocation.to('/noresults')
                }
            })
    }
}

I’ve tried going back to my old code and I can’t seem to get that working now so I’m just going to consolidate my data into one search database and use that with my old website version.