Search.../

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
collectionId
string

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.

propertyName
string

The property to remove the reference from.

referringItem
Object | string

The referring item or referring item's ID.

referencedItem
Object | string | Array<Object> | Array<string>

The referenced item, referenced item's ID, an array of referenced items, or an array of referenced item IDs.

options
Optional
WixDataOptions

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:

Promise<void>

Was this helpful?

Remove a reference

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.

Copy Code
1import wixData from 'wix-data';
2
3// ...
4
5wixData.removeReference("movies", "actors", "00001", "12345")
6 .then(() => {
7 console.log("Reference removed");
8 })
9 .catch((error) => {
10 console.log(error);
11 });
12
Remove references using an array

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.

Copy Code
1import wixData from 'wix-data';
2
3// ...
4
5wixData.removeReference("movies", "actors", "00001", ["12345", "67890"])
6 .then(() => {
7 console.log("Reference removed");
8 })
9 .catch((error) => {
10 console.log(error);
11 });
12