Skip to content

Commit

Permalink
Fix _id overwrite error in createCompetition
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso committed Feb 18, 2025
1 parent b4f8bce commit aa1de31
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 @@ -429,12 +429,14 @@ export default class ClientApi extends NextApiTemplate<ApiDependencies> {
),
);

season.competitions = [...season.competitions, String(comp._id)];
const { _id, ...updatedSeason } = season;

updatedSeason.competitions = [...season.competitions, String(comp._id)];

await db.updateObjectById(
CollectionId.Seasons,
new ObjectId(season._id),
season,
updatedSeason,
);

// Create reports
Expand Down

0 comments on commit aa1de31

Please sign in to comment.