Skip to content

TypeScript code snippet – mongodb node findone How to handle no results using promises?

const findUser = async function (params) { 
    try {  return await User.findOne(params)
    } catch(err) { console.log(err) }
}

const userSteve = findUser({firstName: Steve})
See also  Java code snippet - How do I change the opacity of a JButton?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.