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.37 kB
{"version":3,"file":"get-single-count.mjs","names":["formatter"],"sources":["../../../src/services/processed-images/get-single-count.ts"],"sourcesContent":["import formatter from \"../../libs/formatters/index.js\";\nimport { ProcessedImagesRepository } from \"../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\n\nconst getSingleCount: ServiceFn<\n\t[\n\t\t{\n\t\t\tkey: string;\n\t\t},\n\t],\n\tnumber\n> = async (context, data) => {\n\tconst ProcessedImages = new ProcessedImagesRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\n\tconst processedImageCountRes = await ProcessedImages.count({\n\t\twhere: [\n\t\t\t{\n\t\t\t\tkey: \"media_key\",\n\t\t\t\toperator: \"=\",\n\t\t\t\tvalue: data.key,\n\t\t\t},\n\t\t],\n\t\tvalidation: {\n\t\t\tenabled: true,\n\t\t},\n\t});\n\tif (processedImageCountRes.error) return processedImageCountRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: formatter.parseCount(processedImageCountRes.data?.count),\n\t};\n};\n\nexport default getSingleCount;\n"],"mappings":"2GAIA,MAAM,EAOF,MAAO,EAAS,IAAS,CAM5B,IAAM,EAAyB,MAAM,IALT,EAC3B,EAAQ,GAAG,OACX,EAAQ,OAAO,EAGmC,CAAC,CAAC,MAAM,CAC1D,MAAO,CACN,CACC,IAAK,YACL,SAAU,IACV,MAAO,EAAK,GACb,CACD,EACA,WAAY,CACX,QAAS,EACV,CACD,CAAC,EAGD,OAFI,EAAuB,MAAc,EAElC,CACN,MAAO,IAAA,GACP,KAAMA,EAAU,WAAW,EAAuB,MAAM,KAAK,CAC9D,CACD"}