Created
April 24, 2022 20:03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beforeOperation: async ({ resolvedData, item, context }) => { | |
if (resolvedData?.products) { | |
const dbItems = await context.query.Cart.findOne({ | |
where: { id: item ? (item.id as string) : '' }, | |
query: 'products { id }', | |
}); | |
if (dbItems.products.length) { | |
await context.query.CartProduct.deleteMany({ | |
where: dbItems.products.map((el: { id: string }) => ({ | |
id: el.id, | |
})), | |
}); | |
} | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment