Skip to content

[JITERA] Add Book Model

chi le requested to merge feat/add-book-model-1749196946 into main

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

  1. Book Schema Definition:

    • Created a new file models/Book.js that defines the schema for the Book model using Mongoose. The schema includes fields such as title, author, publishedDate, genre, and ISBN.
  2. Validation:

    • Added validation rules for each field to ensure data integrity. For example, the title field is required, and the ISBN field must be unique.
  3. Methods:

    • Implemented instance methods for the Book model, including getBookInfo to retrieve formatted book information and isPublished to check if the book has been published.
  4. 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.

Merge request reports