query.include() not returning all fields

I am using a database “AircoKeuzeHulp”, with one multi-reference field to another database “OfferteOnderdelen”.

When I use a query with include(), it stopped returning all the fields, it only returns the standard fields.
When I query the same item directly, I do get all the fields returned.

var offerte = ( await wixData . query ( “Aircokeuzehulp” ). eq ( “_id” , offerteID ) .include(“offerteonderdelen”) . find ()). items [ 0 ];
console . log ( "offerte: " + JSON . stringify ( offerte ));

output doesn’t contain all fields:


offerte:
 {"email": "anon",
 	"achternaam": "anon",
 	"_id": "414ae9b0-f4ea-498b-ba09-5ecc2bbfc450",
 	"_owner": "4d36071a-5a44-4bd2-9d8d-0ddc90882710",
 	"_createdDate": "2022-04-13T13:26:31.260Z",
 	"_updatedDate": "2022-04-13T13:26:31.260Z",
 	"offerteonderdelen": [{
 		"_id": "f974e6b7-30e3-49f2-bf00-18fb11b2929e",
 		"_owner": "4d36071a-5a44-4bd2-9d8d-0ddc90882710",
 		"_createdDate": "2022-04-13T13:26:14.354Z",
 		"_updatedDate": "2022-04-13T13:26:14.354Z"
 	}],
 ...
 	(other fields omitted)
 }

var test = (await wixData.query("OfferteOnderdelen").eq("_id", "f974e6b7-30e3-49f2-bf00-18fb11b2929e").find()).items[0];
console.log("test: " + JSON.stringify(test));

output does contain all fields:


test: {
	"gekozenModel": "tundra",
	"model": "ec515f11-c8a3-415e-9e2a-05f48ffc2cd1",
	"_id": "f974e6b7-30e3-49f2-bf00-18fb11b2929e",
	"_owner": "4d36071a-5a44-4bd2-9d8d-0ddc90882710",
	"_createdDate": "2022-04-13T13:26:14.354Z",
	"_updatedDate": "2022-04-13T13:26:14.354Z",
	"breedte": "450",
	"hoogte": "260",
	"lengte": "300",
	"ruimte": "slaapkamer",
	"onderhoudscontract": true,
	"condenspomp": true
}

In the content manager, the reference column also doesnt show the value of the Primary field.


After re-opening the content manager it does:

What could be wrong?

The .include method (for multi-reference field) is limited to 50 referenced items.
If you need to get more than the limit, you shouldn’t use .include() but queryReferenced( ). See:
https://www.wix.com/velo/reference/wix-data/queryreferenced

Thanks for your reply.
I am aware of that, but in this case there is only 1 referenced item.

From the docs:
Each returned item can include up to 50 referenced items. If there are more than 50 referenced items, only 50 are returned when the query is run and the partialIncludes property of the returned WixDataQueryResult is true.

If there were more than 50 items, than the first 50 should be returned.

In my case: all the items are returned, but with only 4 fields : _id, _createdDate, updateDate and _owner. All other fields have gone missing.
That doesn’t seem to be expected behaviour of the 50 items-limit?

Also note the UI of the Content manager isn’t showing the referenced Primary Field as well on first load.

@ronald28659 Sorry. You explained it perfectly in the first post. I didn’t read it carefully.
But the offerte _id value in the first example (with the include method) is not the same as in your direct query test. So maybe item 414ae9b0-f4ea-498b-ba09-5ecc2bbfc450 just doesn’t have a defined value for these fields. Are you sure they’re filled in (not only in live collection)?

@jonatandor35
I am querying Offerte with offerte _id 414ae9b0-f4ea-498b-ba09-5ecc2bbfc450

This offerte item has a multireferencefield called offerteonderdelen , which is included by calling include().

This query returns referenced item with _id f974e6b7-30e3-49f2-bf00-18fb11b2929e in the offerteonderdelen array

It is this same referenced item I am querying directly in the second example.


(Offerteregels is the display name of offerteonderdelen)

@ronald28659 Now I got you, but I have no idea how to solve it.
Maybe someone else?

1 Like

@ronald28659 Hi Ronald, the team has investigated, but we need more information. Please submit a ticket to Customer Care and include your site URL, relevant databases, and the code in question. Share the ticket # in this thread and tag me so I can ensure it gets seen by the team quickly. Thanks!

1 Like

It would seem this was related to a performance problem with the Content Manager in general. (some tables didn’t load at all, after a time out and later we received general 500 error messages when visiting our sites).
After submitting a ticket, the problem disappeared as sudden as it appeared. Hopefully it won’t come back.