I am looking to validate user details that are being registered in the Meteor.users
collection.
Currently, I can easily verify username uniqueness by querying the database field username
of the Meteor.users
collection like this:
var obj = Meteor.users.findOne({username: userId});
if (obj != null) {
alert('Username is already in use');
}
However, I am unsure how to check email uniqueness as well. According to the documentation, the emails
field is an array containing objects with address
and verified
fields. How should I construct a filter for this?