API Update: wix-dataset getItems()

The wix-dataset API has been updated so that we now enforce the passing of values for the fromIndex and numberOfItems parameters when calling the getItems() function.

If you do not use the getItems() function in your code, or if you use it and pass values for the fromIndex and numberOfItems parameters as documented in the API Reference, you can safely ignore this message.

If you have code that relied on the old behavior, where the getItems() function would return up to 1000 items if called without passing any parameters, you will need to update your code to pass values for the fromIndex and numberOfItems parameters.

For example:

// old code - WILL NO LONGER WORK!
$w("myDataset").getItems()
 .then( (results) => {
   // do something with results 
 } );

// new code - you need to change it to something like this
const totalItems = $w("myDataset").getTotalCount();

$w("myDataset").getItems(0, totalItems)
 .then( (results) => {
   // do something with results 
 } );

If you encounter any problems, please let us know here and we will do our best to help you.

1 Like

Please add offset soon to this function

Hi,

Are we now required to call getTotalCountI() and pass its return value to getItems()? I had the following code which was working up until recently:
Note in the snippet below and <sort_col> are strings specific to my database collection
and the dataset being queried has 10 records.

$w(β€˜β€™).setSort(wixData.sort().ascending(β€˜<sort_col>’));
return $w().getItems(0, 100) // Number of items was hard-coded to 100
.then((data) => {
for (let i = 0; i < data.totalCount; i++) {
// This used to work until Saturday Feb 10; item would be of type Object and could be accessed
// On Sun Feb 11 item became undefined and could not access its properties
let item = data.items[i]; // item is now undefined

I had to modify my code as follows:
$w(β€˜β€™).setSort(wixData.sort().ascending(β€˜<sort_col>’));
const totalItems = $w(.getTotalCount();
return $w().getItems(0, totalItems)
.then((data) => {
for (let i = 0; i < data.totalCount; i++) {
let item = data.items[i]; // item is now defined and type Object and is working correctly again

I also see the Database Collections toolbar now has import and export to CSV capabilities - awesome!

now all form on my site got a problem on multiple choice how to fix https://araiki.wixsite.com/mzeebaba/form

Do you use getItems in your code? If you do just add the new parameters according to sample above.

This come complicated issue for me i was already created a form and was function well and start to modify by adding code i don’t have any ideas how to change code! can you help me

Yes but do you use getItems anywhere in your code?

Yes

can you visit my site to experience my problem https://araiki.wixsite.com/mzeebaba/form

Just did! Your error says your Continents collection does not exist. Do you have a data collection called Continents?

no

Your code refernce a data collection named that, check that. If you donΓ€t mind please start a new thread in questions & answers. This forum and thread is for new getItems questions only.