VICTOR OMONDI Posted on Jan 11, 2020 MongoDB Tip - Querying For Single Document #mongodb If you're querying for a single document, prefer findOne over find Usecase: To find a user by an email field One possible approach: User.find({email: 'shubworkmail@gmail.com'}); Enter fullscreen mode Exit fullscreen mode Better Approach: User.findOne({email: 'shubworkmail@gmail.com'}); Enter fullscreen mode Exit fullscreen mode Top comments (0) Subscribe Submit Preview Dismiss Code of Conduct • Report abuse
Top comments (0)