[JITERA] Enhance Reader Model for Borrowed Books Management
Created by: chi-jitera
Overview
This pull request updates the existing Reader model to better manage the list of books that readers have borrowed. The enhancements include additional fields to track the borrowing status and due dates for each borrowed book.
Changes Made
-
Added
statusField:- This field tracks whether the book is currently borrowed or has been returned. It can have two values:
borrowedorreturned, with the default set toborrowed.
- This field tracks whether the book is currently borrowed or has been returned. It can have two values:
-
Added
dueDateField:- This field specifies the date by which the book should be returned. It helps in managing overdue books and sending reminders to readers.
Updated Reader Model Code
const mongoose = require('../config/db');
const readerSchema = new mongoose.Schema({
name: { type: String, required: true },
contactInfo: { type: String, required: true },
borrowedBooks: [{
book: { type: mongoose.Schema.Types.ObjectId, ref: 'Book' },
borrowDate: { type: Date, default: Date.now },
returnDate: { type: Date },
status: { type: String, enum: ['borrowed', 'returned'], default: 'borrowed' },
dueDate: { type: Date }
}]
});
module.exports = mongoose.model('Reader', readerSchema);
This update will allow for more effective management of borrowed books, ensuring that we can track their status and due dates efficiently.