Hello,
I have an 85% working code but I am struggling to figure out how to return “wixData.filter” results, instead of just the first row from a collection.
-
This is meant to search if todays date is between the dates in Collection Column 1 (ID: fromDate ) and Column 2 (ID: toDate ).
-
Once it finds the correct row, it filters the collection to that row. It is supposed to then return filtered text from the 3rd Column (ID: name2 ) to a simple, front end, text box.
Is there a way for this to return the 3rd column filtered text (instead of only the first row like it is doing now)? There should always be a single filtered row.
$w.onReady(function () {
$w("#dataset1").onReady( () => {
let d = new Date(); // get today's date
d.setHours(0,0,0,0); // clear out the time
$w("#dataset1").setFilter(wixData.filter() // start filter
.lt("fromDate", d) // fetch date column1
.or( //or
wixData.filter().gt("toDate", d) //fetch date column2
)
)
.then( () => { // start text results
wixData.query('ThisisaCollectionName')
.find().then(results => {
console.log(results)
let todaytext = results.items[0].name2;
$w('#text50').text = todaytext
});
});
});
});
Any ideas or suggestions would be greatly appreciated.
Thank you.