Skip to content

Commit

Permalink
feat(#579): get backup data from body before deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
jannis-baum committed Apr 4, 2023
1 parent c85c350 commit 7f83b33
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion anni/src/pages/api/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const api: NextApiHandler = async (req, res) =>
return { successStatus: 200, data };
},
POST: async () => {
const data: Record<string, object> = req.body.data;

await dbConnect();

await Promise.all(
Expand All @@ -35,7 +37,6 @@ const api: NextApiHandler = async (req, res) =>
),
);

const data: Record<string, object> = req.body.data;
await Promise.all(
Object.entries(data).map(([name, docs]) =>
mongoose.models[name].create(docs, {
Expand Down

0 comments on commit 7f83b33

Please sign in to comment.