Need to check user input is duplicated or no before submit

Dear wix team

I have database which contains information of existing users .
we need check for every submit that if user already exist in database in that case user should get an error msg / alert for already existing information .

Hi Ammar!

I suggest you to read about query( ) from the wix-data API.
Using this method you can check if some information already exists in your database.
Make sure that you use unique fields (such as Email address, given ID, etc.) to determine if the user exists or not. Here’s a code example:

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

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

			});
	});
});

Best of luck!
Doron. :slight_smile:

Dear Doron,

thanks for the replay

can you make code example:
for collection database not wixUsers need wixData

Br

I am having the same problem was there no work around on this?