GenericCrudService is an abstract class that offers a suite of CRUD (Create, Read, Update, Delete) operations tailored for Mongoose models. It’s designed for easy extension, allowing you to quickly implement CRUD features for various entities. GenericCrudService acts as your toolbox for routine database operations. It’s equipped to handle basic tasks efficiently, such as adding, finding, updating, and deleting data.

Core Functions for Daily Operations

We’ve integrated key operations like create, find, findOne, findById, update, and delete into GenericCrudService. These functions are crucial for numerous applications, addressing everyday data manipulation needs. Without a generic client, you’d be writing the same methods for each model, leading to redundant efforts. GenericCrudService eliminates this repetition. It offers a unified approach to handling models, enhancing efficiency and maintaining a clean codebase.

Flexibility to Customize

Need to implement specific functionality not covered by GenericCrudService? No problem. The design is inherently flexible, allowing you to introduce new features to cater to unique project requirements.

Methods

create

Creates a new document.

findOne

Finds one document based on conditions.

find

Finds documents based on conditions.

findOneAndUpdate

Updates a single document based on conditions and returns the updated document.

updateOne

Updates a single document based on conditions.

updateMany

Updates multiple documents based on conditions.

deleteOne

Deletes a single document based on conditions.

delete

Deletes multiple documents based on conditions.

archiveOne

Archives a single document.