UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.53 kB
{"version":3,"file":"delete-for-documents.mjs","names":[],"sources":["../../../src/services/preview-sessions/delete-for-documents.ts"],"sourcesContent":["import { PreviewSessionsRepository } from \"../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\n\nconst deleteForDocuments: ServiceFn<\n\t[\n\t\t{\n\t\t\tcollectionKey: string;\n\t\t\tdocumentIds: number[];\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\tif (data.documentIds.length === 0) {\n\t\treturn { error: undefined, data: undefined };\n\t}\n\n\tconst PreviewSessions = new PreviewSessionsRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\tconst deleteRes = await PreviewSessions.deleteMultiple({\n\t\twhere: [\n\t\t\t{\n\t\t\t\tkey: \"entry_collection_key\",\n\t\t\t\toperator: \"=\",\n\t\t\t\tvalue: data.collectionKey,\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"entry_document_id\",\n\t\t\t\toperator: \"in\",\n\t\t\t\tvalue: data.documentIds,\n\t\t\t},\n\t\t],\n\t});\n\tif (deleteRes.error) return deleteRes;\n\n\treturn { error: undefined, data: undefined };\n};\n\nexport default deleteForDocuments;\n"],"mappings":"4DAGA,MAAM,EAQF,MAAO,EAAS,IAAS,CAC5B,GAAI,EAAK,YAAY,SAAW,EAC/B,MAAO,CAAE,MAAO,IAAA,GAAW,KAAM,IAAA,EAAU,EAO5C,IAAM,EAAY,MAAM,IAJI,EAC3B,EAAQ,GAAG,OACX,EAAQ,OAAO,EAEsB,CAAC,CAAC,eAAe,CACtD,MAAO,CACN,CACC,IAAK,uBACL,SAAU,IACV,MAAO,EAAK,aACb,EACA,CACC,IAAK,oBACL,SAAU,KACV,MAAO,EAAK,WACb,CACD,CACD,CAAC,EAGD,OAFI,EAAU,MAAc,EAErB,CAAE,MAAO,IAAA,GAAW,KAAM,IAAA,EAAU,CAC5C"}