From 3a8fd82daebd7b92cec73f15e75bb2e38d01120a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sat, 30 Dec 2023 16:02:27 -0500 Subject: [PATCH] fix(api): fix new subscriptions not being saved to database for some reason i forgot to set the field referenced by $addToSet to `body.push` lmao #justcopyandpastethings --- server/api/user/me/subscriptions.put.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/api/user/me/subscriptions.put.ts b/server/api/user/me/subscriptions.put.ts index 4238fff..b6a974b 100644 --- a/server/api/user/me/subscriptions.put.ts +++ b/server/api/user/me/subscriptions.put.ts @@ -6,6 +6,7 @@ export default eventHandler(async (ev) => { isLoggedIn(ev); // note: debounced batched update const body = await readBody(ev); + console.log(body); await User.findByIdAndUpdate(ev.context.currentUser!._id, { $pull: { "subscriptions.authors": { @@ -24,13 +25,13 @@ export default eventHandler(async (ev) => { { $addToSet: { "subscriptions.authors": { - $each: body.pull?.authors ?? [], + $each: body.push?.authors ?? [], }, "subscriptions.bands": { - $each: body.pull?.bands ?? [], + $each: body.push?.bands ?? [], }, "subscriptions.stories": { - $each: body.pull?.stories ?? [], + $each: body.push?.stories ?? [], }, }, },