QueryReferenced result limited to 50

Im using the Queryreferenced to overcome the limitation of include giving only 50 references at most.
Changing the three variables given the Queryreferenced for security.

await wixData.queryReferenced(“Collection”, “MyReferenceID”, “MyTable”)
.then((results) => {
console.log(results.items.length);
//console.log(results.items.map(item => item.title));
HighschoolsOnly = results.items.map(item => item.title);
})

But i seem to still be limited to recieving only 50 references of highschools (exist 130 ish).
This is troublesome since i use it in a search to limit results to not at all or only be highschools but all references not included in these 50 references saved in “HighschoolsOnly” will still be shown breaking my search field.

anyone that can explain this ?

1 Like

All DB queries are limited to 50 by default. You can change it.
See here:
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#limit

Limit does not function in collaboration with queryreference only Query alone.
My apologies for not clarifying ive already tested this.
wixData.queryReferenced(“Collection”, “MyReferenceID”, “MyTable”) .limit(1000) make an error instead of allowing 1000 results.

is this resolved?

Unfortantly not actually. You currently having the same issue ?

@clsnlsen Yes I do. The API for reference fields interactions works really bad. I managed to worked around, by fitlering a dataset. In my case, I wanted to obtain all the objects where the reference field exists. So query of empty/notempty/etc didnt work. There are only like 10 type of IDs for the reference field, and therefore are filter the dataset for any of those 10 IDs, and thats how I got all the items I wanted, fitlered by a reference field, and overcomming the 50 query limitation.

Please WIX, improve your reference fields interactions.

@yisrael-wix is there any way to query more than 50 referenced fields?
Doing it the other way around, with am api “query” and “.hasSome”, can be up to 100, but it still ignores the “.limit(x)” if there are more than 100 items. Is there any upadate on this from WiX side?

Are you asking about collection fields, or returned items from a database query.

As you can see in the API, the default for limit() is 50, and maximum is 1000:

@yisrael-wix
I’ll answer here to keep up with the main thread. When querying with a referenced field with mroe than 100 values fails

This option gives an error that ot doesnt recognise “.limit(x)” function
return wixData.queryReferenced( “MyColleciton” , someId, “MyReferencedField” , options)
.limit(limit)
.skip(skip)
.then((results) => {

The following works upto 100 referenced items regardless of the value inside lmit. More than 100 items it fails
let options = { “suppressAuth” : true };
return wixData.query( “Stores/Orders” )
.hasSome( “MyCollectionReferencedField” , someValue)
.descending( “number” )
.limit(10)
.skip(10)
.find(options)
.then((results) => {

If I take out the referenced field it works ok
let options = { “suppressAuth” : true };
return wixData.query( “Stores/Orders” )
.descending( “number” )
.limit(10)
.skip(10)
.find(options)
.then((results) => {

From the api limit() :
" the maximum limit for the Wix Stores/Product collection is 100. "
But I want to do a manual pagination of referenced fields of 10 items on each batch, if the total amount of referenced fields is above 100 it fails, regardless of my limit set to 10.

Is there any advanced on this? If not, I have to change my DB architecture, which impacts my functionalities, and I prefer to do that now, rather than later

Thank you.

Aha! So you’re using Stores/Orders…

Yest, but I am doing a manual pagination of 10 items on each bacth. So I am querying 10 Stores/Orders objects, filtered by a referenced field. If the referenced field ID appears more than 100 times in the Stores/Orders collection it fails, regardless of my limit set to 10.
Did I explain myself? The behaviour seems contradictory.

@miguelhongo90 Hmm, I think I understand. Not sure if it’s a database or a Stores issue. I’ll have to run this by QA and see what they say.

Does it work for referenced fields that appear fewer than 100 times?

@yisrael-wix Yes, when the referenced field appears less than 100 times works perfect, i can do the manual pagination ok. But now the reference field appears 105 times, and I cannto do it.

This is the error I get on backend log:
{"message":"Too many values (105). Limit: 100.","details":{}}

@miguelhongo90 It seems that the Claes, the original poster in this thread, had a similar issue.

I’ll let you know what QA says.

Awesome.
Do u have an aproximate timeline in mind?
So I can plan my work.
Thanks a lot.

@miguelhongo90 It depends on if the QA guy is still talking to me. :wink:

Tough to estimate, but I hope to have an answer in a day or so.

@yisrael-wix Hi Yisrael! did u get any views from QA? :slight_smile:

@yisrael-wix ? :slight_smile:

No info yet from the devs, but I’m pushing.