Checking if member exists in Members/PrivateMembersData

Trying to check if member already exists in Members collection but no sucess.
Backend:

export async function MemberExists(Email) {
const results = await wixData.query(“Members/PrivateMembersData”)
.eq(‘loginEmail’, Email)
.find();
if (results.totalCount === 0) {
return true
}
}

Any advice how to correctly write call to MemberExists in frontend code? Seems that either backend function is returning undefined results, either I do not correctly call this function. Appreciate any suggestions!

What are you looking to use this searching for an existing email address for?
https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields

If it is for a simple search of your Members then you can do it by doing something like this below and also have a read of the api reference for query too. https://www.wix.com/corvid/reference/wix-data.html#query

import wixUsers from 'wix-users';
import wixData from 'wix-data';

$w.onReady(function () {
	wixUsers.currentUser.getEmail().then((email) => {
		return wixData.query('Members/PrivateMembersData')
			.eq('loginEmail', email)
			.find()
			.then(result => {
				if (result.totalCount === 0) {
					//New user
				} else {
					//Existing user
				}

			});
	});
});

Or if it is to do it whilst a user is trying to sign up as a member of your site, then you can just use this tutorial as the code is already done for you.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

Nayeli (Code Queen) has the same tutorial shown here that also includes a search on the profile page for duplicate entries too.
https://codequeen.wixsite.com/membership-dashboard
Video for tutorial above.
https://www.youtube.com/watch?v=yLCOqsVHhD0

Plus, make your own custom branded and designed login and sign up lightboxes too so that you don’t have to navigate away from the page or use Wix own windows to login or signup.
https://www.wix.com/corvid/reference/wix-users.html#login
https://www.wix.com/corvid/reference/wix-users.html#register

Again Nayeli (Code Queen) has a good tutorial about making your own lightboxes.
https://support.totallycodable.com/en/article/create-custom-log-in-sign-on-screen-using-wix-code
Video for tutorial above.
https://www.youtube.com/watch?v=QbH8_eudjbE&list=PL16sLBOBeiCPEnJFIejV9jCTx_ZNcyE8_&index=2&t=0s

Although, if you do the lightbox options, then you will need to change your sign up settings to show that, otherwise you will still have Wix own windows appearing first.
https://support.wix.com/en/article/corvid-enabling-custom-site-registration

Issue is that I do not have any user logged in. Sequence is: user enters email in textbox with type email → this input is checked in the Wix Memebers database → if no such member, then it is registered and logged in.
Also, I see You using this code in frontend - are Members/PrivateMembersData functions accessible from frontend code?


Hi, I’m trying to do the same thing but using the new wixMembers instead of the deprecated wixUsers. Ultimately, I’m trying to create an error message on my custom sign-up lightbox for someone who is trying to “sign-up” using an email address that already exists as a site member. Any suggestions?