Removing Item from Favorites

I have been trying to set up a favorites system and could only find versions where it is set up as a store wishlist, or where they only get as far as adding to the favorites. I have been able to add them to the favorites, but I have been having issues with checking to see if it is already added so there are not duplicates and removing the item from favorites. This is on a dynamic page for the item. Here is the code I have so far:

import wixData from ‘wix-data’ ;
import wixUsers from ‘wix-users’ ;

//dynamicDataset is the dataset for the game item on they dynamic page
//MemberFavesNRates is the dataset storing favorites and ratings of the items for each member
//The favorite is stored as a reference to the game item in MemberFavesNRates

let user = wixUsers . currentUser ;

$w . onReady ( async function () {
if ( user . loggedIn ) {
checkFav (); //whether to display Favorite or Unfavorite
} else {
$w ( “#favButton” ). label = “Sign In” ;
}
});

function checkFav ( ) {
let favResult = wixData . query ( “MemberFavesNRates” ). eq ( “dynamicDataset” , $w ( “#dynamicDataset” ). getCurrentItem (). _id );
console . log ( favResult );
if ( favResult ) {
$w ( “#favButton” ). label = “Unfavorite” ;
} else {
$w ( “#favButton” ). label = “Favorite” ;
}
}

export function favButton_click ( event ) {
let favResult = wixData . query ( “MemberFavesNRates” ). eq ( “dynamicDataset” , $w ( “#dynamicDataset” ). getCurrentItem (). _id );
if ( favResult ) {
wixData . insert ( “MemberFavesNRates” , { favorites : $w ( “#dynamicDataset” ). getCurrentItem (). _id });
} else {
wixData . remove ( “MemberFavesNRates” , favResult [ 0 ]);
}
checkFav ();
}