Get index of item in dataset

I’m accessing the dataset through front-end code, directly from my Wix website. Only doing queries.

The only other alternative I can think of is to iterate through the entire dataset until I find the matching email, but this would not be the most optimized method.

Should I iterate through my sorted list until I find the match and display the resulting counter?

Below is a portion of my code

// From Query to Position
$w ( “#button32” ). onClick (() => {

wixData . query ( "Waitlist" ) 
. eq ( 'type' ,  'Waitlist' ) 
. count () 
. then ( ( waitlistCount ) => {      //return total number of people on waitlist 

	console . log ( 'People registered '  +  waitlistCount ); 

	**let**  email  =  $w ( "#input13" ). value . toUpperCase ();       //to upper to match 
	**let**  refURL  =  wixLocation . query ;          
	console . log ( email ); 
	
	wixData . query ( "Waitlist" ) 
	. eq ( 'email' ,  email ) 
	. find ( options ) 
	. then ( ( results ) => { 

		**if** ( results . items . length  >  0 ) { 
			console . log ( 'User exists' ); //only one email allowed, if found result = 1 
			**let**  items  =  results . items ; 
			**let**  refID  =  items [ 0 ]. referralCode ;  //referral code to display 
			**let**  position  =  items [ 0 ]. position ;  //manual position I'm doing temp. 
			**let**  friendsReferred  =  items [ 0 ]. totalReferrals ;   //sum of friends ref. 
			**let**  referralLink  =  '[MY WEBSITE]?refID='  +  refID . toString () 
			$w ( "#text117" ). text  =  referralLink ;  //display URL with referral code 
			$w ( "#text120" ). text  =  position . toString () +  "/"  +  waitlistCount ; //position out of total people in waitlist 
			$w ( "#text118" ). text  =  friendsReferred . toString (); //num of friends that have referred and joined 
			$w ( '#EmptyFullStateBox' ). changeState ( "Position" ); //display the results in a different state 
		} 

		**else**  { 
			console . log ( 'User does not exist' );      //if does not exist, show error and prompt user to sign up instead 
			$w ( "#text124" ). show (); 
		} 

	} ); 
} ); 

} );