Skip to content

[JITERA] Implement Reader Module for Managing Book Borrowers

chi le requested to merge feat/reader-module-1750781020 into main

Created by: chi-jitera

Overview

This pull request introduces the Reader module, which is responsible for managing readers who borrow books. The module includes the creation of the Reader model, service, controller, and routes to facilitate reader-related operations.

Changes Made

  1. Created Reader Model:

    • A new file named Reader.js has been added in the /models directory.
    • The schema for the Reader model includes the following attributes:
      • name: A string that is required.
      • contactInfo: A string that is required.
      • borrowedBooks: An array of ObjectIds referencing the Book model.
      • borrowDate: A date that defaults to the current date.
      • returnDate: A date that can be set when the book is returned.
    const mongoose = require('../config/db');
    
    const readerSchema = new mongoose.Schema({
        name: { type: String, required: true },
        contactInfo: { type: String, required: true },
        borrowedBooks: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Book' }],
        borrowDate: { type: Date, default: Date.now },
        returnDate: { type: Date }
    });
    
    module.exports = mongoose.model('Reader', readerSchema);
  2. Next Steps:

    • The next steps will involve creating the Reader service to handle business logic related to readers, implementing the Reader controller for HTTP request handling, defining routes for reader operations, and updating the database configuration to ensure proper connectivity for CRUD operations.

This implementation sets the foundation for managing readers in the application and will be expanded in subsequent commits.

Merge request reports