If you're familiar with SQL, you may be familiar with a security vulnerability known as SQL Injection. Good information on web application security best practices can be found at owasp.org. The Open Web Application Security Project (OWASP) is a community-driven initiative to catalog and educate users on the security vulnerabilities present in web applications in order that we can more effectively combat against malicious hackers. If you've ever had your email, social account, or website hacked, you know the pain that ensues—digital identity theft. OWASP's listing for SQL injection is here: https://owasp.org/www-community/attacks/SQL_Injection.
So why are we talking about SQL if we're using a NoSQL database in the form of MongoDB? Because SQL injection doesn't exist in MongoDB. "GREAT!", you might say, "My security woes are solved!" This, unfortunately, is not the case. Coupled with the idea of refactoring to improve efficiency...