removeReference( )
Removes a reference from the specified property.
Description
The removeReference()
function returns a Promise that resolves when a
reference to the referenced item(s) is removed from the specified property in
the referring item. The Promise is rejected if the current user does not
have update permissions for the collection.
Calling the removeReference()
function does not trigger any hooks.
Note: The
removeReference()
function is not supported for Single Item Collections.
Syntax
function removeReference(collectionId: string, propertyName: string, referringItem: Object | string, referencedItem: Object | string | Array<Object> | Array<string>, [options: WixDataOptions]): Promise<void>
removeReference Parameters
NAME
TYPE
DESCRIPTION
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 property to remove the reference from.
The referring item or referring item's ID.
The referenced item, referenced item's ID, an array of referenced items, or an array of referenced item IDs.
An object containing options to use when processing this operation.
Returns
Fulfilled - When the references have been removed. Rejected - The error that caused the rejection.
Return Type:
Was this helpful?
This example removes a reference to the item with ID 12345 from the Actors field of the item in the Movies collection with the ID 00001.
1import wixData from 'wix-data';23// ...45wixData.removeReference("movies", "actors", "00001", "12345")6 .then(() => {7 console.log("Reference removed");8 })9 .catch((error) => {10 console.log(error);11 });12
This example removes a reference to the items with IDs 12345 and 67890 from the Actors field of the item in the Movies collection with the ID 00001.
1import wixData from 'wix-data';23// ...45wixData.removeReference("movies", "actors", "00001", ["12345", "67890"])6 .then(() => {7 console.log("Reference removed");8 })9 .catch((error) => {10 console.log(error);11 });12