Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
44 lines
1.4 KiB
Plaintext
44 lines
1.4 KiB
Plaintext
import { preferencesCollectionSlug } from './config.js';
|
|
export const deleteUserPreferences = async ({ collectionConfig, ids, payload, req })=>{
|
|
if (collectionConfig.auth) {
|
|
await payload.db.deleteMany({
|
|
collection: preferencesCollectionSlug,
|
|
req,
|
|
where: {
|
|
or: [
|
|
{
|
|
and: [
|
|
{
|
|
'user.value': {
|
|
in: ids
|
|
}
|
|
},
|
|
{
|
|
'user.relationTo': {
|
|
equals: collectionConfig.slug
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
key: {
|
|
in: ids.map((id)=>`collection-${collectionConfig.slug}-${id}`)
|
|
}
|
|
}
|
|
]
|
|
}
|
|
});
|
|
} else {
|
|
await payload.db.deleteMany({
|
|
collection: preferencesCollectionSlug,
|
|
req,
|
|
where: {
|
|
key: {
|
|
in: ids.map((id)=>`collection-${collectionConfig.slug}-${id}`)
|
|
}
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
//# sourceMappingURL=deleteUserPreferences.js.map |