Skip to content

Commit 2d64d3a

Browse files
committed
Update code
1 parent 81a1d0f commit 2d64d3a

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

services/investments/handler.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,11 @@ export const invest = async (event, ctx, callback) => {
5959
});
6060
}
6161

62-
const updateInvestorPromise = db.updateOne(data.investorId, USER_REGISTRATIONS_TABLE, {
63-
"eventID;year": "kickstart;2025" // hardcoded
64-
}, {
65-
balance: investor.balance - data.amount
66-
});
62+
const updateInvestorPromise = db.updateDB(data.investorId, { balance: investor.balance - data.amount }, USER_REGISTRATIONS_TABLE);
6763

68-
const updateTeamPromise = db.updateOne(data.teamId, TEAMS_TABLE, {
69-
"eventID;year": "kickstart;2025" // hardcoded
70-
}, {
71-
funding: team.funding + data.amount
72-
});
64+
const updateTeamPromise = db.updateDB(data.teamId, { funding: team.funding + data.amount }, TEAMS_TABLE);
7365

74-
const updateTransactionPromise = db.create({
66+
const createInvestmentPromise = db.create({
7567
id: uuidv4(), // partition key (?)
7668
["investor#team"]: `${data.investorId}#${data.teamId}`, // sort key (?)
7769
investorId: data.investorId,
@@ -82,7 +74,7 @@ export const invest = async (event, ctx, callback) => {
8274
["eventID;year"]: "kickstart;2025",
8375
}, INVESTMENTS_TABLE);
8476

85-
await Promise.all([updateInvestorPromise, updateTeamPromise, updateTransactionPromise]);
77+
await Promise.all([updateInvestorPromise, updateTeamPromise, createInvestmentPromise]);
8678

8779
return helpers.createResponse(200, {
8880
message: "Investment successful"

0 commit comments

Comments
 (0)