WixDataQuery - FUNCTIONS - ne()

Someone has some code example using the ne () function passing an array to it.

I am trying to understand how this function works when we pass an array to it.

#WixDataQuery
#ne()

https://www.w3schools.com/js/js_arrays.asp

Take note too that there was an issue with the ne() function back in May on Booking Collections.
https://www.wix.com/corvid/forum/community-discussion/bug-filter-ne-not-working

However, as that was four months ago now, I would hope that it was definitely fixed by now, plus you are probably not even using it in the same way too!

@yisrael-wix Can you confirm that everything is fine and dandy with it now?

@givemeawhisky

Yes I saw this post:
https://www.wix.com/corvid/forum/community-discussion/bug-filter-ne-not-working

@yisrael-wix
Apparently not yet, I tried in many ways and the ne() function does not accept more than one argument.
When I pass only one argument works but two or more of the error.
It seems to me that analyzing the documentation does not accept arrays just one value. But I may be wrong.

.ne() is not supposed to work with 2 arguments (as far as I know)

Plus you can use arrays with it…
If the value of the propertyName property is an Array, ne() includes items in which none of the elements of the Array match the specified value.
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#ne

@givemeawhisky That’s the other way.
You can use .ne(“fieldKey”, value1) if field1 in your collection is an array like [“value1”, “value2”].
You can’t use .ne(“fieldKey”, value1, value2)

@jonatandor35
@givemeawhisky
@yisrael-wix

Apparently not really accept.
But this value: any generated doubt if I was only value , it would be clearer

Sintaxe: ne()

function ne(propertyName: string, value: any): WixDataQuery

@marciokricheldorf yes, it’s not consistent. For the .eq() it is:

function eq(propertyName: string, value: *): WixDataQuery

and i think it means the same.

Anyway, for querying 2 arguments, I think you should just chain another .ne(), something like:

query.ne("filedKeyX", value1).ne("fieldKeyX", value2).find()

@jonatandor35

For example this way ( in red ), only non-array members

The variable
varMyArray is my array

wixData.query(“Members/PrivateMembersData”)
.not(wixData.query(“Members/PrivateMembersData”)
.hasSome(“_id”, varMyArray )
)
.find()
.then((results) => {
if (results.items.length > 0) {
let items = results.items;
let firstItem = items[0];
let totalCount = results.totalCount;
let pageSize = results.pageSize;
let currentPage = results.currentPage;
let totalPages = results.totalPages;
let hasNext = results.hasNext();
let hasPrev = results.hasPrev();
let length = results.length;
let query = results.query;
console.log(firstItem)
} else {
console.log(“Your code here if nothing is found”)
}
})
. catch ((error) => {
let errorMsg = error.message;
let code = error.code;
console.log("An error has occurred " + code + " - " + errorMsg)
});

I’m passing this on for clarification. Starting with the docs team to see if it’s a docs issue (error, inconsistency, incomplete, etc).