We are excited to announce the following recent additions to the Wix Code API.
isEmpty() / isNotEmpty()
You can now refine your wix-data queries to only match items where a specified property is empty or is not empty. A property is considered empty if it doesn't exist, is null, or is undefined.
Example: Retrieve author items that have a non-empty bio.
import wixData from 'wix-data';
// ...
wixData.query("authors")
.isNotEmpty("bio")
.find()
.then( (results) => {
// do something with the results
} )
.catch( (error) => {
// handle the error
} );
To learn more, see isEmpty and isNotEmpty in the API reference.
Dataset Paging APIs
You can now work with your dataset's pages using the following wix-dataset APIs:
getCurrentPageIndex() - Gets the index of the dataset's current page.
getPageSize() - Gets the dataset's page size.
getTotalPageCount() - Gets the number of pages in the dataset.
hasNextPage() - Indicates if there is a next page of data.
hasPreviousPage() - Indicates if there is a previous page of data.
loadMore() - Loads the next page of data in addition to the current data.
loadPage() - Loads the specified page.
nextPage() - Moves to the next page of data.
previousPage() - Moves to the previous page of data.
setPageSize() - Sets the dataset's page size.
To learn more about dataset paging, see Data Paging in the API Reference.
postMessage()
If your site is embedded within another site, you can now use the wix-window postMessage() function to send messages from the inner site to the outer one.
To learn more, see postMessage() in the API Reference.
Hi Wix Good but how do I get back (refresh) all items? I filter DB with isNotEmpty and can't use isEmpty to show all items again and can't use both at the same time cause result is 0. im using button to call a refresh or clear the filter. Any idea?
DA
Speaking of new APIs, are there any updates on the Wix Contacts API (and the related custom membership signup as well as the updating of Roles and Permissions)?
Thanks Andreas .
1. .isNotEmpty("bio") will check that a field in your data collection is not empty, superb.
2. The paging functions is used so that you can display your records on pages by 10 for example and let the user click load more and then load in 10 more.
ok?
What are the concrete applications of these new apis, please ?
YEAH! Good work there, send beer to the team :)