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
1 line
2.2 KiB
Plaintext
1 line
2.2 KiB
Plaintext
{"version":3,"sources":["../../src/preferences/deleteUserPreferences.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Payload } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { preferencesCollectionSlug } from './config.js'\n\ntype Args = {\n collectionConfig: SanitizedCollectionConfig\n /**\n * User IDs to delete\n */\n ids: (number | string)[]\n payload: Payload\n req: PayloadRequest\n}\nexport const deleteUserPreferences = async ({ collectionConfig, ids, payload, req }: Args) => {\n if (collectionConfig.auth) {\n await payload.db.deleteMany({\n collection: preferencesCollectionSlug,\n req,\n where: {\n or: [\n {\n and: [\n {\n 'user.value': { in: ids },\n },\n {\n 'user.relationTo': { equals: collectionConfig.slug },\n },\n ],\n },\n {\n key: { in: ids.map((id) => `collection-${collectionConfig.slug}-${id}`) },\n },\n ],\n },\n })\n } else {\n await payload.db.deleteMany({\n collection: preferencesCollectionSlug,\n req,\n where: {\n key: { in: ids.map((id) => `collection-${collectionConfig.slug}-${id}`) },\n },\n })\n }\n}\n"],"names":["preferencesCollectionSlug","deleteUserPreferences","collectionConfig","ids","payload","req","auth","db","deleteMany","collection","where","or","and","in","equals","slug","key","map","id"],"mappings":"AAIA,SAASA,yBAAyB,QAAQ,cAAa;AAWvD,OAAO,MAAMC,wBAAwB,OAAO,EAAEC,gBAAgB,EAAEC,GAAG,EAAEC,OAAO,EAAEC,GAAG,EAAQ;IACvF,IAAIH,iBAAiBI,IAAI,EAAE;QACzB,MAAMF,QAAQG,EAAE,CAACC,UAAU,CAAC;YAC1BC,YAAYT;YACZK;YACAK,OAAO;gBACLC,IAAI;oBACF;wBACEC,KAAK;4BACH;gCACE,cAAc;oCAAEC,IAAIV;gCAAI;4BAC1B;4BACA;gCACE,mBAAmB;oCAAEW,QAAQZ,iBAAiBa,IAAI;gCAAC;4BACrD;yBACD;oBACH;oBACA;wBACEC,KAAK;4BAAEH,IAAIV,IAAIc,GAAG,CAAC,CAACC,KAAO,CAAC,WAAW,EAAEhB,iBAAiBa,IAAI,CAAC,CAAC,EAAEG,IAAI;wBAAE;oBAC1E;iBACD;YACH;QACF;IACF,OAAO;QACL,MAAMd,QAAQG,EAAE,CAACC,UAAU,CAAC;YAC1BC,YAAYT;YACZK;YACAK,OAAO;gBACLM,KAAK;oBAAEH,IAAIV,IAAIc,GAAG,CAAC,CAACC,KAAO,CAAC,WAAW,EAAEhB,iBAAiBa,IAAI,CAAC,CAAC,EAAEG,IAAI;gBAAE;YAC1E;QACF;IACF;AACF,EAAC"} |