appendToArray( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Refines a patch operation to append the specified value to the specified array field.

Method Declaration
Copy
function appendToArray(field: string, value: any): WixDataPatch;
Method Parameters
fieldstringRequired

Array field to append the specified value to. Nested fields can be specified using dot notation. For example: address.street.


valueanyRequired

Value to append to the specified array field.

Returns
Return Type:WixDataPatch
Append to array
JavaScript
import { items } from "@wix/data"; async function appendToArray() { const updatedItem = await items .patch("BlogPosts", "fb071093-9a40-432d-ae1f-2e5966fecbfa") .appendToArray("tags", "travel") .appendToArray("tags", "lifestyle") .run(); const id = updatedItem._id; // "fb071093-9a40-432d-ae1f-2e5966fecbfa" const tags = updatedItem.tags; // ["vacations", "travel", "lifestyle"] }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?