This works well when email in dataset is all lowercase but fails if not exact case.
import wixData from 'wix-data';
import wixUsers from 'wix-users';
$w.onReady(function () {
// ...
let user = wixUsers.currentUser;
let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"
let isLoggedIn = user.loggedIn; // true
let userRole = user.role; // "Member"
user.getEmail()
.then((email) => {
let userEmail = email; // "user@something.com"
$w("#dynamicDataset").setFilter(wixData.filter()
.eq("email", userEmail)
);
console.log(userEmail);
console.log(wixData.filter());
console.log(email)
});
});
Hello buddy,
so you say that the “email” and useremail do not match when you give in an email on registration with capital letters in it?
kristof.
I have a dataset with an “email” field that contains emails with upper AND lower case email addresses. It seems that the login emails are stored in lower case, which is fine. I am comparing the two to populate a form from the dataset info. When the emails match (case wise) it works fine. I want to grab the email from the dataset, force it to lower case, then use that as a dataset filter to give them access to change ONLY their record.
Hi buddy.
i think i know what you need then.
try using
.contains(“email”,userEmail)
instead of .eq(“email”,userEmail)
its not case senstive
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#contains
kristof.
That worked perfectly! Thank you.
I’m happy to hear that!
don’t forget to add it as best answer so people see that it has been answerd and if people search for it they can see that there is an answer to be found here
kristof.