wix-data
to the Data Items SDKAs 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:
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.
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:
The bulkInsert()
method now returns a full WixDataBulkResult
object.
The bulkRemove()
method now returns a full WixDataBulkResult
object.
The bulkSave()
method now returns a full WixDataBulkResult
object.
The bulkUpdate()
method now returns a full WixDataBulkResult
object.
The insert()
method no longer modifies the original object passed to it. For example:
Note: The way Wix Data handles the item in the collection remains unchanged.
The query()
and WixDataQuery
methods have been updated with the following changes:
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:
Changes have been made to the parameters accepted by the following WixDataQuery
methods:
The and()
method now accepts a single WixDataFilter
parameter.
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:
For example:
The not()
method now accepts a single WixDataFilter
parameter.
The or()
method now accepts a single WixDataFilter
parameter.
The query result object WixDataResult
no longer includes the query
and partialIncludes
properties.
The queryReferenced()
method includes the following changes:
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:
The save()
method no longer modifies the original object passed to it. For example:
Note: The way Wix Data handles the item in the collection remains unchanged.
The update()
method no longer modifies the original object passed to it. For example:
Note: The way Wix Data handles the item in the collection remains unchanged.
Wix Data errors include the following changes:
Wix Data errors now follow the standardized error format.
Learn more about errors in Wix APIs.
Filter validation error messages now indicate the violating field in the following format:
The following Wix Data errors have the updated format:
Learn more about Wix Data error codes.