I'm new to Mongo and am using Mongoose as an ORM.
For user registration, I'm using email as the unique. I want to check if the email is already in use, and if it's not, then do something (perhaps save, perhaps next registration step, etc).
Sorry for what seems like a simple questions, but I haven't found an answer for it.
Unless it's "upsert". Which means inserting the document, even if I'm not quite ready to...
Are you asking how to find a document?
db.users.findOne({email => '[email protected]'})
If it returns something, document exists. Otherwise, it doesn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With