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:
queryReferenced()
function does not trigger any hooks.queryReferenced()
function with multiple-item reference fields, and not with single-item (regular) reference fields.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.
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.
The referring item or referring item's ID.
The property that contains the references to the referenced items.
An object for controlling the order of the returned referenced items.