Skip to main content

2 posts tagged with "mongoose"

View All Tags

· 7 min read
Sivabharathy

When deciding between Prisma and Mongoose for a MongoDB-based application, there are several factors to consider. Both are powerful tools, but they are designed with different paradigms and use cases in mind. Below is a breakdown to help you understand when you might prefer one over the other.

· 4 min read
Sivabharathy

Mongoose pre hooks are middleware functions that run before certain operations, such as saving or validating a document. They are useful for a variety of tasks, including data validation, transformation, and managing related data.

Why Use Pre Hooks?

Pre hooks allow you to:

  • Validate or sanitize data before it’s saved to the database.
  • Automatically perform actions like hashing passwords.
  • Clean up related data before deletion.
  • Modify queries before executing them.