wix-data.query().eq() is not filtering data

let myQuery = wixData . query ( “Billing/Invoices” );
myQuery . eq ( ’ number ’ , “0000054” );

myQuery . find ()
. then ( ( results ) => {
if ( results . items . length > 0 ) {
console . log ( “getPaymentHistory RESULT length” , results . items . length );
} else {
console . log ( “getPaymentHistory no length” );
}
} )

. catch ( ( err ) => {
console . log ( “getPaymentHistory err” , err );
} );


I am querying invoices Collections filtering with specific number. However, it returns entire collection set. As you can see “number” is the field type and “0000054” is a valid entry. Can someone suggest what is wrong with this?


You forgot to bind the reprieved data to the repeater.
If you wish you can filter a dataset instead (but in that case, don’t run a query but use setFilter() )

Hi JD, I am no expert than the code I have written. Can you please let me know how to bind data to repeater(in code)?

In my code, I am getting 50 invoices. I have to iterate for next 50 and so on to get full list and filter myself. I dont want this to happen. I am looking for a query that just retrieves one record that matches the invoice number. If I get 1 for results . items . length it makes sense for me to look into data(I think this is what you meant by bind data to repeater?)
.

I do not know what is your issue, but this one works properly…

import wixData from 'wix-data';

$w.onReady(function () {xxx();});

function xxx() {console.log("My function running...")
    wixData.query("collection')'
    .eq('number', '0000044')
    .find()
    .then((res)=>{console.log("RESULTS: ", res);
        if(res.items.length>0) {
            console.log("RESULT-length", res.items.length);
        } else {console.log("No data found!");}
    }).catch((err)=> {console.log("getPaymentHistory err", err);});
}

There is a syntax error in the line wixData . query ( "collection’ )’

But even after fixing this issue, I still get [“RESULT-length”,50] with your code.

Realy strange! I tested it and it gave me → just the item i was searching for <—
You entered your own VALUES to test it, for example…

.eq('number','0000071')

Can you show your whole console-log of your result(s)? If you still get more then just one - - > open one of the results completely. Would be nice if you could do that in google-browser.

BTW: Yes →

wixData.query("collection')'

→ that was a typo :sweat_smile:

I received update from support team that number field is not filterable for Billing/Invoices collection.

The secret has been revealed :grin: