Unable to enable .limit(10) on a Database Query

I have a series of searches in a switch statement. All work fine, but one of the searches could return hundreds of items. My main database query limits to 10 items with a Load More button at bottom.

I tried to implement the API .limit() but it gives a runtime error: not a function

Please advise.

Thanks
JD

How are you using .limit()? What is the code?

Thanks Yisrael, here is the code snipit…

case “1”: (wixData.query(‘CVOA-Registry’).contains(‘dash’, $w(‘#searchDash’).value))
.find()
//.limit(10)
.then(res => {
$w(‘#repeater1’).data = res.items;
console.log("SEARCHED FOR DASH: ", $w(‘#searchDash’).value)
});
break ;

Gave runtime error… ".limit(10)’ is not a function?

The .limit() should come before the .find() . That’s most likely your problem.

YES! That fixed it!.
I have a couple of other GO Live issues, should I post them on that other forum post and could you help with those please?

OOPS… but, at the bottom of the page I have a button to get next 10 entries. I is not honoring the search parms but rather going back to top of list and showing FIRST 10

A dataset keeps track of the location within the collection. However, when dealing directly with a collection you will need to keep track of where you are. You can use .skip() to skip over the current entries so that you can get the “next” entries. Make sure you keep the track of what entry number you’re on so you can then do proper next and previous. You can keep the current index in session storage or a page variable.

Thanks Yisrael, I have somewhat got around the problem by changing methodology… See new Forum Post: https://www.wix.com/code/home/forum/questions-answers/repeater-with-search-filter

JD

I was just informed by the club owners to drop the YEAR field. So the problem will go away when I drop that search capability.