I have 2 datasets on my dynamic page for all rental properties; Rentals (#dynamicdataset) and Properties (#dataset1). I also have another dataset for Neighborhoods.
I have set up a sort for price, beds, baths, and neighborhoods. Neighborhoods is a reference field in the rentals and properties datasets.
The search function works for everything except neighborhoods. How do I account for sorting neighborhoods in my code??
So i have this example laying around from when i first learned it because its a quite hard thing to do.
async function queryHasSome() {
let blue = (await wixData.query('Colors')
.eq('title', 'Blue')
.find()).items[0];
let green = (await wixData.query('Colors')
.eq('title', 'Green')
.find()).items[0];
let res = await wixData.query('Items')
.hasSome('colors', [green._id, blue._id])
.find();
$w('#textBoxHasSome').value =
JSON.stringify(res.items, undefined, ' ');
$w('#tableHasSome').rows = res.items;
}
This example have the Colors collection which is referenced in the Items collection. by first finding what you want in the colors and then using this with .hasSome or all will allow you to search from the reference field in the Items collection and filter from that.
Hope that make sense, prefer leaving a little learning left for people.