queryReferenced( )


Gets the full items referenced in the specified property.

The queryReferenced() function returns a Promise that resolves to the full items that are referenced in the specified property of the item from the specified collection. The Promise is rejected if the current user does not have read permissions for the specified collection or the collection containing the referenced items.

For example, suppose you have a Movies collection with an Actors field that contains references to items in a People collection. Querying the Movies collection using queryReferenced() returns the relevant People items referenced in the Actors field of the specified Movies item. Meaning, it returns the full actor information for all actors in the specified movie.

The queryReferenced() function can be used instead of a standard query() with an include() to overcome the limitations of the include() function.

You can optionally control the order of the returned referenced items by passing a WixDataQueryReferencedOptions object.

Notes:

  • Calling the queryReferenced() function does not trigger any hooks.
  • You can only use the queryReferenced() function with multiple-item reference fields, and not with single-item (regular) reference fields.
  • The queryReferenced() function is not supported for Single Item Collections.

For a discussion of when to use the similar include() function and when to use queryReferenced(), see Querying Items that Reference Other Items.

Method Declaration
Copy
Method Parameters
collectionIdstringRequired

The ID of the collection that contains the referring item.

To find your collectionId, select the Databases tab in the Velo Sidebar. Hover over your collection, click the three dots, and select Edit Settings.


itemunionRequired

The referring item or referring item's ID.


propertyNamestringRequired

The property that contains the references to the referenced items.


optionsWixDataQueryReferencedOptions

An object for controlling the order of the returned referenced items.

Returns
Return Type:Promise<WixDataQueryReferencedResult>
Was this helpful?
Yes
No