use('EduvosLibrary');
// Insert borrowedbooks data first
db.borrowedbooks.insertOne({
memberID: "MEM001",
ISBN: "978-001",
dateBorrowed: "2024-01-15",
dueDate: "2024-02-15",
returnDate: "2024-02-10",
fineAmount: 0
});
db.borrowedbooks.insertOne({
memberID: "MEM002",
ISBN: "978-002",
dateBorrowed: "2024-03-01",
dueDate: "2024-03-15",
returnDate: null,
fineAmount: 50
});
// Calculate total fine revenue
print('Total fine revenue:');
db.borrowedbooks.aggregate([
{
$group: {
_id: null,
totalFineRevenue: { $sum: "$fineAmount" }
}
},
{
$project: {
_id: 0,
totalFineRevenue: 1
}
}
]).forEach(result => print(JSON.stringify(result)));
To embed this project on your website, copy the following code and paste it into your website's HTML: