refactor(api): use null propagation for fields in subscription payload
This commit is contained in:
parent
088232f750
commit
50e860df5d
@ -9,13 +9,13 @@ export default eventHandler(async (ev) => {
|
|||||||
await User.findByIdAndUpdate(ev.context.currentUser!._id, {
|
await User.findByIdAndUpdate(ev.context.currentUser!._id, {
|
||||||
$pull: {
|
$pull: {
|
||||||
"subscriptions.authors": {
|
"subscriptions.authors": {
|
||||||
$in: body.pull.authors,
|
$in: body.pull?.authors,
|
||||||
},
|
},
|
||||||
"subscriptions.bands": {
|
"subscriptions.bands": {
|
||||||
$in: body.pull.bands,
|
$in: body.pull?.bands ?? [],
|
||||||
},
|
},
|
||||||
"subscriptions.stories": {
|
"subscriptions.stories": {
|
||||||
$in: body.pull.stories,
|
$in: body.pull?.stories ?? [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -24,13 +24,13 @@ export default eventHandler(async (ev) => {
|
|||||||
{
|
{
|
||||||
$addToSet: {
|
$addToSet: {
|
||||||
"subscriptions.authors": {
|
"subscriptions.authors": {
|
||||||
$each: body.pull.authors,
|
$each: body.pull?.authors ?? [],
|
||||||
},
|
},
|
||||||
"subscriptions.bands": {
|
"subscriptions.bands": {
|
||||||
$each: body.pull.bands,
|
$each: body.pull?.bands ?? [],
|
||||||
},
|
},
|
||||||
"subscriptions.stories": {
|
"subscriptions.stories": {
|
||||||
$each: body.pull.stories,
|
$each: body.pull?.stories ?? [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user