Asked by:
Check If email exists in MongoDB

Question
-
User-150677302 posted
Hi, In registration form how to check whether the email already exists or not in db... when i click submit button if the email is already exists then it should show like " email already exists please try another email ? What query to write in MongoDB ???
Thursday, December 24, 2020 8:47 AM
All replies
-
User753101303 posted
Hi,
Assuming you are learing about queying MongoDB, it seems you could use Linq : LINQ (mongodb.github.io)
From Expressions (mongodb.github.io) my understanding is that you could also (which happens behing the scene whn using Linq) to create a document with property names, each value being an object that describes the filtering you want.
For this particular purpose you could use the ASP.NET Identity (the built in API to manage users) with something such as GitHub - g0t4/aspnet-identity-mongo: A mongodb provider for the new ASP.NET Identity framework.
Thursday, December 24, 2020 9:39 AM -
User1535942433 posted
Hi aadi765432,
As far as I think,you need to return a promise in validateEmailAccessibility : function validateEmailAccessibility(email){ return User.findOne({email: This query will select all documents in the inventory collection to check files exist and null value})}.
Also,you could use linq $count or any() method to match documents.
More details,you could refer to below articles:
https://stackoverflow.com/questions/6411280/mongodb-how-to-check-for-existence
Best regards,
Yijing Sun
Friday, December 25, 2020 2:48 AM -
User-150677302 posted
LINQ ? Will read about it.
Didn't knew about that
Friday, December 25, 2020 2:14 PM -
User1535942433 posted
Hi aadi765432,
If you need to learn more about linq,you could refer to below article:
https://mongodb.github.io/mongo-csharp-driver/1.11/linq/
Best regards,
Yijing Sun
Tuesday, December 29, 2020 9:31 AM