I'm have 7 databases that I want to provide a search between them. My goal is to show a searched item based on some tag that I would add to databases.
For example: The user search's "fast food". I want to search between all of my 7 databases and show what item contains "fast food" tag.
@Lista Locall
This is an example of how you would search multiple fields in multiple collections:
import wixData from 'wix-data' $w.onReady(function () { $w('#searchButton1').onClick(function () { wixData.query("firstCollectionName") .contains("collectionFieldKey1", $w("#searchInput1").value) .or(wixData.query("firstCollectionName") .contains("collectionFieldKey2", $w("#searchInput1").value)) .find() .then((results1) => { let results1Items = results1.items; console.log(results1Items); wixData.query("secondCollectionName") .contains("collectionFieldKey1", $w("#searchInput1").value) .find() .then((results2) => { let results2Items = results2.items; console.log(results2Items); const allResults = results1Items.concat(results2Items); console.log(allResults); }) }) }) })
export function iTitle_keyPress(event) { let searchValue = $w('#iTitle').value; $w('#dataset2').setFilter(wixData.filter().contains('stProficientAsCrew',searchValue)), $w('#dataset2').setFilter(wixData.filter().contains('fullName', searchValue)), $w('#dataset2').setFilter(wixData.filter().contains('nationality', searchValue)); }
Hi,
You would need to do a query, with a contains filter, for each database.
I don't know what you're trying to accomplish, but you might want to consider using just once database collection, and add an extra field (e.g. category) which would indicate which of the 7 databases it "belongs to". This would make database queries simpler and more streamlined. For example, regarding your original question, with only one collection, you would only need one query, not 7.
Good luck,
Yisrael