isReferenced( )
Checks if a reference to the referenced item exists in the specified property of the referring item.
Description
The isReferenced()
function returns a Promise that resolves to true
if
the referring item contains a reference to the referenced item in the
specified property. The Promise is rejected if the current
user does not have read permissions for the collection.
Calling the isReferenced()
function does not trigger any hooks.
Note: The
isReferenced()
function is not supported for Single Item Collections.
Authorization
Request
This endpoint does not take any parameters
Response Object
Fulfilled - Whether the referring item contains a reference to the referenced item or not. Rejected - The error that caused the rejection.
Returns an empty object.
Status/Error Codes
Was this helpful?
Get referenced items
This example checks if the item in the Movies collection with the ID 00001 has a reference in its Actors field that refers to an item with the ID 12345.
1import wixData from 'wix-data';23// ...45wixData.isReferenced("movies", "actors", "00001", "12345")6 .then((result) => {7 let isReferenced = result; // true8 })9 .catch((err) => {10 let errorMsg = err;11 });12