Hide button if user has already submitted a form entry

Dear community,

I was wondering what is the best way to hide a button if a user has already submitted a form entry to a database?

When I tried the code below, it ended up locking members out of the members pages.

let user = wixUsers.currentUser;
let userId = user.id;
wixData.query(“#dataset1”)
.eq(“_id”, userId)
.find()
.then((results) => {
if (results.items.length === 0) {
$w(‘#button1’).show();
} else {
$w(‘#button1’).hide();
}
});

Thank you.

#hidebutton #submit #form #database

Did you ever get this figured out?