include( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Includes referenced items for the specified fields.

The include() method refines a search so that the items returned in the search results include the full referenced items for the specified fields.

For example, suppose you have a books collection with an author field that references an authors collection. Searching the books collection with an include("author") returns the relevant book items, and each item includes the full referenced author item in the book's author field.

When searching a collection that contains a reference field without using the include() method:

  • Single reference field: returned items contain only the ID of the referenced item, and not the full referenced items.
  • Multiple reference field: returned items do not contain the multiple reference field at all.

When including a field with multiple references, the following limitations apply:

  • Only one field with multiple references can be included.
  • The search returns an error if more than 50 items are returned, regardless of any search limit set using the limit() method.
  • Each returned item can include up to 50 referenced items. If there are more than 50 referenced items, only 50 are returned, and the partialIncludes field of the returned WixDataResult is true.

Note: The include() method is not supported for single-item collections.

Method Declaration
Copy
Method Parameters
fieldsArray<string>Required

Fields for which to include referenced items.

Returns
Return Type:WixDataSearch
Errors

This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?