Migrate from wix-data to the Data Items SDK

As part of Wix's transition from Velo to the next-generation JavaScript SDK, you can now use the Data Items SDK module for site development. While this module closely mirrors the Velo wix-data module, there are several functionality changes that might require modifications to your existing site code.

Learn more about migrating from Velo to the SDK.

Below are important changes to be aware of when migrating to the Data Items SDK module:

Permission elevation

When calling some methods of the Data Items SDK API, you might need to override permission checks. To do that, use elevate(). The Data Items SDK API doesn't support the options.suppressAuth parameter.

Learn more about permission elevation when developing websites.

aggregate()

The aggregate() and WixDataAggregate methods can now return the total number of processed items.

When calling the WixDataAggregate method run(), set options.returnTotalCount to true to include the totalCount and totalPages properties in the aggregation result. For example:

Copy

bulkInsert()

The bulkInsert() method now returns a full WixDataBulkResult object.

bulkRemove()

The bulkRemove() method now returns a full WixDataBulkResult object.

bulkSave()

The bulkSave() method now returns a full WixDataBulkResult object.

bulkUpdate()

The bulkUpdate() method now returns a full WixDataBulkResult object.

insert()

The insert() method no longer modifies the original object passed to it. For example:

Copy

Note: The way Wix Data handles the item in the collection remains unchanged.

query()

The query() and WixDataQuery methods have been updated with the following changes:

Total item count

Total item count is no longer returned by default. The WixDataQuery methods distinct() and find() no longer accept the options.omitTotalCount parameter. The query result only includes the totalCount and totalPages properties if options.returnTotalCount is set to true. For example:

Copy

WixDataQuery

Changes have been made to the parameters accepted by the following WixDataQuery methods:

and()

The and() method now accepts a single WixDataFilter parameter.

include()

The include() method now accepts a query limit parameter. You can limit the number of query results you want to retrieve by specifying a field name and a query limit in the following format:

Copy

For example:

Copy

not()

The not() method now accepts a single WixDataFilter parameter.

or()

The or() method now accepts a single WixDataFilter parameter.

WixDataResult

The query result object WixDataResult no longer includes the query and partialIncludes properties.

queryReferenced()

The queryReferenced() method includes the following changes:

Total item count

Total item count is no longer returned by default. The queryReferenced() method no longer accepts the options.omitTotalCount parameter. Instead, the query result only includes the totalCount and totalPages properties if options.returnTotalCount is set to true. For example:

Copy

save()

The save() method no longer modifies the original object passed to it. For example:

Copy

Note: The way Wix Data handles the item in the collection remains unchanged.

update()

The update() method no longer modifies the original object passed to it. For example:

Copy

Note: The way Wix Data handles the item in the collection remains unchanged.

Wix Data errors

Wix Data errors include the following changes:

Errors are standardized

Wix Data errors now follow the standardized error format.

Learn more about errors in Wix APIs.

Validation errors specify violating fields

Filter validation error messages now indicate the violating field in the following format:

Copy

The following Wix Data errors have the updated format:

  • WDE0056
  • WDE0057
  • WDE0058
  • WDE0059
  • WDE0060

Learn more about Wix Data error codes.

Did this help?