J.D
April 16, 2019, 8:53pm
1
Hi,
I’d like to filter my dataset like this
.eq("a", "b")
.eq("c", "d")
.eq("e", "f") **OR** isEmpty("e")
The results must match to conditions 1 AND 2 AND 3
How can I do it?
I’ve read this one https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#or but it’s not the same.
Thanks in advance,
J.D.
#setFilter , #filter , #and (), #or (), #dataset
1 Like
Shan
April 17, 2019, 12:23am
2
Hi,
I just tested this and it should work, just change it accordingly to filter a dataset
wixData.query("myCollection")
.eq("a", "b")
.eq("c", "d")
.eq("e", "f")
.or(
wixData.query("myCollection")
.eq("a", "b")
.eq("c", "d")
.isEmpty("e")
)
.find()
.then( (results) => {
//do cool stuff here
});
[UPDATED] For filtering dataset (tested)
export function button1_click(event) {
$w("#dataset1").setFilter( wixData.filter()
.eq("a", "b")
.eq("c", "d")
.eq("e", "f")
.or(
wixData.filter()
.eq("a", "b")
.eq("c", "d")
.isEmpty("e")
)
)
.then( () => {
console.log('Done');
});
}
J.D
April 17, 2019, 1:00am
3
Thank you, Shan,
Meanwhile, I did it a little bit differently, and it seems to work, but your way looks more straightforward. I’ll try to apply it next time
Thanks again,
J.D.