Skip to content

Commit

Permalink
Don't try to overwrite team _id in createSeason
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso committed Feb 18, 2025
1 parent caa1731 commit 664a516
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/api/ClientApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,14 @@ export default class ClientApi extends NextApiTemplate<ApiDependencies> {
gameId,
),
);
team!.seasons = [...team!.seasons, String(season._id)];

const { _id, ...updatedTeam } = team;
updatedTeam.seasons = [...team.seasons, String(season._id)];

await db.updateObjectById(
CollectionId.Teams,
new ObjectId(teamId),
team!,
updatedTeam!,
);

return res.status(200).send(season);
Expand Down

0 comments on commit 664a516

Please sign in to comment.