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.01 kB
{"version":3,"file":"delete-query-builder.mjs","names":[],"sources":["../../../../src/libs/db/query-builder/delete-query-builder.ts"],"sourcesContent":["import type { DeleteQueryBuilder } from \"kysely\";\nimport type { LucidDB } from \"../types.js\";\nimport type { QueryBuilderWhere } from \"./index.js\";\n\nconst deleteQueryBuilder = <Table extends keyof LucidDB, O>(\n\tquery: DeleteQueryBuilder<LucidDB, Table, O>,\n\twhere: QueryBuilderWhere<Table>,\n) => {\n\tlet kyselyQuery = query;\n\n\tfor (const { key, operator, value, condition } of where) {\n\t\tconst shouldApply =\n\t\t\ttypeof condition === \"function\" ? condition() : condition;\n\t\tif (shouldApply === false) continue;\n\n\t\tkyselyQuery = kyselyQuery.where(key, operator, value);\n\t}\n\n\treturn kyselyQuery;\n};\n\nexport default deleteQueryBuilder;\n"],"mappings":"AAIA,MAAM,GACL,EACA,IACI,CACJ,IAAI,EAAc,EAElB,IAAK,GAAM,CAAE,MAAK,WAAU,QAAO,eAAe,GAEhD,OAAO,GAAc,WAAa,EAAU,EAAI,KAC7B,KAEpB,EAAc,EAAY,MAAM,EAAK,EAAU,CAAK,GAGrD,OAAO,CACR"}