tried to compare:
not “”
not ‘’
not NULL
not null
But still received the unwanted rows.
Thanks:)
tried to compare:
not “”
not ‘’
not NULL
not null
But still received the unwanted rows.
Thanks:)
have to tries it like this?
wixData.query(“myCollection”)
.gt(“age”, 25)
.not(
wixData.query(“myCollection”)
.eq(“field”, null)
)
.find()
Hi Andreas,
How would I best apply this code? if I don’t want to get (“age”, 25), but simply filter out empty fields in a collumn from a collection and have a clean display in the table with visible data? The below code I try to apply won’t work.
wixData.query(“myCollection”)
.not(“field”, null)
)
.find()
.then(res => {
$w(“#table2”).rows = res.items;
});
}
I would like to hear your suggestions. Thanks in advance.
Kind regards,
Quyen Nguyen
Hey
I have feature requested this function but you might the below trick. I have no idea if it works, but if it does please let me know and if you need code let me know.
Create an array like
Just make sure you have the id field with you because all item needs a unique id when populated in an repeater.
Hi Andreas,
Sorry, it didn’t work.
I was thinking of doing a filter setting in the dataset using the following conditions:
“field” one of the fields in the collections
Condition “is not”
with one of these conditions:
‘’
“”
null
“null”
‘null’
but it seems not to work. It does work with condition “is” or “contains” >0 or >‘null’ or >null.
The results is either you see all of them or you see nothing. Do you happen to know the correct code to use the filter correctly? Thanks in advance.
Kind regards,
Quyen Nguyen
Hi Quyen,
You can use the regular JS functions to filter all records with a certain empty field. You can use the Array filter function. You should check for each item of the results if it has the relevant property using the hasOwnProperty function. I’ve added the code below to demonstrate:
import wixData from 'wix-data';
$w.onReady(function () {
wixData.query("collectionName")
.find()
.then((results) => {
let filteredResults = results.items.filter(item => {
item.hasOwnProperty('fieldName') === true
});
})
.catch((err) => {
let errorMsg = err;
});
});
Good luck!
Tal.
Hi Tal,
Thank you. I will try it. It takes a bit more time as I am still learning how to apply codes.
Kind regards,
Quyen Nguyen
These are the filters you need:
https://www.wix.com/corvid/reference/wix-data/wixdatafilter/isempty
https://www.wix.com/corvid/reference/wix-data/wixdatafilter/isnotempty
thank you Jarad