I have to login with phonenumber (containing coutry code like '380325632589') Here 380 is country code and rest is phone number. But current database saves country code and phone number separately. So I can't find it by normal find query.
var UserSchema = new Schema({
username: {
type: String,
trim: true
},
email: {
type: String,
trim: true
},
password: {
type: String
},
phone_number: {
type: String
},
country_code: {
type: String
}
});
And user can login should login via email or phonenumber so I am going to use a input field as phoneOremail
.
User.findOne(
{
$or: [
{ phone_number: req.body.phoneOremail },
{ email: req.body.phoneOremail }
]
},
function(err, user) {}
);
But it doesn't work because country_code didn't considered. I don't want to create new field that containing countrycode only for this. Thanks.