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
This commit is contained in:
parent 4c9293ec19
commit 3a8fd82dae
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -6,6 +6,7 @@ export default eventHandler(async (ev) => {
isLoggedIn(ev); isLoggedIn(ev);
// note: debounced batched update // note: debounced batched update
const body = await readBody<SubPayload>(ev); const body = await readBody<SubPayload>(ev);
console.log(body);
await User.findByIdAndUpdate(ev.context.currentUser!._id, { await User.findByIdAndUpdate(ev.context.currentUser!._id, {
$pull: { $pull: {
"subscriptions.authors": { "subscriptions.authors": {
@ -24,13 +25,13 @@ export default eventHandler(async (ev) => {
{ {
$addToSet: { $addToSet: {
"subscriptions.authors": { "subscriptions.authors": {
$each: body.pull?.authors ?? [], $each: body.push?.authors ?? [],
}, },
"subscriptions.bands": { "subscriptions.bands": {
$each: body.pull?.bands ?? [], $each: body.push?.bands ?? [],
}, },
"subscriptions.stories": { "subscriptions.stories": {
$each: body.pull?.stories ?? [], $each: body.push?.stories ?? [],
}, },
}, },
}, },