[JITERA] Add Book Model
Created by: chi-jitera
Overview
This pull request introduces a new Book model to the application, which will be used to manage book-related data in the database. The model includes a schema definition and several methods for interacting with book records.
Changes Explained
-
Book Schema Definition:
- Created a new file
models/Book.jsthat defines the schema for the Book model using Mongoose. The schema includes fields such astitle,author,publishedDate,genre, andISBN.
- Created a new file
-
Validation:
- Added validation rules for each field to ensure data integrity. For example, the
titlefield is required, and theISBNfield must be unique.
- Added validation rules for each field to ensure data integrity. For example, the
-
Methods:
- Implemented instance methods for the Book model, including
getBookInfoto retrieve formatted book information andisPublishedto check if the book has been published.
- Implemented instance methods for the Book model, including
-
Exporting the Model:
- Exported the Book model for use in other parts of the application, allowing for easy integration with controllers and services.
This new model will facilitate the management of book data and enhance the overall functionality of the application.