Question: Given the class and structure of a transaction using javascript; Create a Mongoose model for a Transaction. (This is the question) class Transaction { constructor(id,
Given the class and structure of a transaction using javascript;
Create a Mongoose model for a Transaction. (This is the question)
class Transaction {
constructor(id, date, description, category, amount){
this.id = id;
this.date = date;
this.description = description;
this.category = category;
this.amount = amount;
}
}
const getTransactions = () => {
const transactions = [];
transactions.push( new Transaction(1, "01/15/23", "jewelry sales", "credit", 350 ));
transactions.push( new Transaction(2, "01/17/23", "old antique sales", "credit", 2000 ));
transactions.push( new Transaction(3, "01/18/23", "product sales", "credit", 4550 ));
transactions.push( new Transaction(4, "01/20/23", "gift", "credit", 170 ));
transactions.push( new Transaction(5, "01/22/23", "dividend", "credit", 250 ));
transactions.push( new Transaction(6, "01/02/23", "purse", "debit", 150 ));
transactions.push( new Transaction(7, "01/04/23", "boots", "debit", 225 ));
transactions.push( new Transaction(8, "01/05/23", "lunch", "debit", 50 ));
transactions.push( new Transaction(9, "01/09/23", "carnival", "debit", 300 ));
transactions.push( new Transaction(10,"01/11/23", "snacks", "debit", 15 ));
return transactions;
};
module.exports = {
getTransactions
};
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
