QueryReferenced result limited to 50

@clsnlsen @miguelhongo90 Could you guys both please create a reproducible scenario? The devs are asking for this, to make sure they have a proper understanding of the issue. With a simple example, they’ll have something to work with to identify the problem.

If you can, post a link so I can pass this on.

Thanks guys.

Hi @yisrael-wix

The problem is that my CustomCollection " CustomColl " has one item that appears more than 100 times in the Stores/Orders collection.

Step 1:
Through a backend module .
Add more than 100 different order_id to the same item_id
item_id : Is the item that appears more than 100 times in the Orders collection
order_id : One order can be added to multiple items in my “CustomColl”
“myRefField” : Name of my MULTIPLE-REFERENCE field in my “CustomColl”, that refers to “Stores/Orders” app-collection.

return wixData.insertReference( “CustomColl” , “myRefField” , item_id, order_id )
.then((result) => { return 1 ;});

Step 2:
Through another backend module .
Query “Stores/Orders” to obtain all the orders, where the reference-field ( “CustomColl-1” ) refers to the item_id of step 1. To overcome the 50 items per query limitation, we use manual pagination of 10 items per call.

limit = 10; // constant value, it never changes
skip = 0; // first call is set to 0, then 10, then 20, and so on.
let options = { “suppressAuth” : true };
return wixData.query( “Stores/Orders” )
.hasSome( “CustomColl-1” , item_id )
.descending( “anyField” ) // optional
.limit(limit)
.skip(skip)
.find(options)
.then((results) => {
return results.items;
}). catch ((err) => {console.log( "MY ERR: " +err.message); return err; });

Final Result:
There’s an error in my backendlong that is printed in the step2 catch statement:
“[“MY ERR: {"message":"Too many values (227). Limit: 100.","details":{}}”]”

This code was working perfe ctly when item_id had less than 100 references in the multiple-reference field “myRefField” , which refers to the Stores/Orders app-collection.

Or in other words, it worked fine when the " hasSome " query filtered less than 100 objects in the Stores/Orders app-collection
.hasSome( “CustomColl-1” , item_id )

Or in other words, it fails when item_id appears referenced more than 100 times in the Stores/Orders app-collection.

thank you, let me know if u need something more

Please send me the link to the page. If you want, you can duplicate the site first and send me that link. I want to be able to give the devs something they can start with right off instead of having to create a site with data. Thanks

When I duplicate the site, the orders objects are not copied, so the developers will also have to bootstrap the data. Another suggestion?

@miguelhongo90 I’ll check with the devs and see what they say.

Meanwhile, send me the link to the site. I want to see if I’m able to clone the site with the data.

I checked with the devs and they said that the data can’t be copied.

However, they say that’s it’s possible to debug without changing anything on your site. The important thing is to be able to see the scenario that adequately shows the issue.

@yisrael-wix
Ok perfect. There’s a second issue as well that I post on this link:
https://www.wix.com/corvid/forum/community-discussion/hassome-filters-none-when-no-items-matched-in-reference-field

The second problem is, that the “.hasSome(“refField”, someRefID)” filters NONE, when the someRefID has no reference fields. Meaning, in this case, the query should return 0 items and it returns all of them. But, if someRefID has one reference, then the query only passes 1 item (this is ok), and if it has more it works well. Therefore there’s a second error in the “.hasSome”. The first error is what we have been speaking on the thread, and the second error is that “.hasSome” lets all the items passed instead of blocking all of them, when there’s no reference field. To clarify, I am working with multiple-reference-fields

Shall I send you the link through a post on the forum (I’d prefer not to).
Or is there another way?

@miguelhongo90 No one outside of Wix will be able to access the content of your site. If you want, post it here, and I’ll delete it as soon as I copy it.

Make sure you indicate the page and provide any explanations needed.

Thanks

Well, someone from the DB dev team checked this out and said that he doesn’t see any issues with this. Perhaps there’s a misunderstanding about what’s expected to be returned?

@clsnlsen , you originally posted about this. Was this resolved? I see that you mentioned in a comment that it was not resolved…Perhaps I don’t understand this correctly?

@miguelhongo90 , perhaps the explanation for the dev team wasn’t sufficient?

@yisrael-wix Perhaps you’re suffering from a beer deficiency.

Ill make screen shots

It’s OK, don’t bother. They got back to me and said that there is in fact something. Mark it down as a limitation, but he wlll revisit this issue.

The developer may have gotten confused with the printed results in the UI, as they are not aware of the context. I have also made explicit the errors in the UI and brought the backend err message to the front end to make it easier to inspect. Here is the context.

1.A)Recreate the error of limit failing (DummyUser A.)

UI screenshot

UI console log

2.A) Recreate the error of “.hasSome” filtering none (Dummy User J.)

In this case, There’s no catch error, as there is no code error in the “.hasSome”, but its a functionality error in “.hasSome”


UI screen shot, all the data its passed. As user J. has no orders made, the user shouldn’t get any order, but the filter .“hasSome” works incorrectly letting all items pass.

The same issue appears on the Products page, as this user J. hasnt created any product, and therefore it shouldnt be getting any data, but again, it gets all the products. The “.hasSome” PASSES all the items, when it should BLOCK all items. This work ok, when there’s at least one reference item to User J.

3.1 Positive scenario of limit working ok and filtering OK (Dummy User P.)


This user has only one order referenced, and therefore the manual pagination is working properly. This will work ok until user P. has 100 referenced orders, then it will fail, as described in 1.A
Also, the filtering with Dummy User P. works ok, as its only displaying the order that is referenced to this user.

Hi,
Is there an update on this? Thank you :slight_smile:

Here you go…

import wixData from 'wix-data';

let options = {
  "limit": 1000
};

wixData.queryReferenced("movies", "00001", "actors", options)
  .then( (results) => {
    if(results.items.length > 0) {
      let firstItem = results.items[0]; //see item below
    } else {
      // handle case where no matching items found
    }
  } )
 .catch( (err) => {
   let errorMsg = err;
  } );

THIS was the answer I needed and worked perfectly thank you thank you thank you!