Here’s how i’m trying to do it
$w("#dataset1").setFilter(wixData.filter()
.eq('active', true)
.or(
wixData.filter("activations")
.eq('month', 'may')
)
)
The filter doesn’t seem to work properly but doesn’t return any error, it does filter data but not what it is supposed to.
aleksf
March 23, 2020, 1:11pm
2
Hi,
or condition is used with wixData only, not with the datasets.
The code should be something like the following:
import wixData from 'wix-data';
// ...
wixData.query("myCollection")
.lt("age", 25)
.or(
wixData.query("myCollection")
.gt("age", 65)
)
.find()
.then( (results) => {
if(results.items.length > 0) {
let items = results.items;
} else {
// handle case where no matching items found
}
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
You can learn more about or condition here.
Got it, thanks! I have a dataset displaying items and want to set a filter based on the OR condition. Should I make queries and then set the data manually each time?