This commit is contained in:
2026-01-04 12:41:19 +01:00
parent def2f2f057
commit 18e29fa413
8 changed files with 39 additions and 9 deletions
@@ -11,6 +11,7 @@ type Param<T extends {
identifierValue?: string | number;
forceLocal?: boolean;
whereClauseObject?: DsqlCrudParamWhereClause;
targetIds?: (string | number)[];
};
/**
* # Delete DB Entry Function
@@ -18,5 +19,5 @@ type Param<T extends {
*/
export default function deleteDbEntry<T extends {
[k: string]: any;
} = any, K extends string = string>({ dbContext, dbFullName, tableName, identifierColumnName, identifierValue, forceLocal, whereClauseObject, }: Param<T, K>): Promise<APIResponseObject<PostInsertReturn>>;
} = any, K extends string = string>({ dbContext, dbFullName, tableName, identifierColumnName, identifierValue, forceLocal, whereClauseObject, targetIds, }: Param<T, K>): Promise<APIResponseObject<PostInsertReturn>>;
export {};
+6 -2
View File
@@ -21,7 +21,7 @@ const conn_db_handler_1 = __importDefault(require("../../../utils/db/conn-db-han
* @description
*/
function deleteDbEntry(_a) {
return __awaiter(this, arguments, void 0, function* ({ dbContext, dbFullName, tableName, identifierColumnName, identifierValue, forceLocal, whereClauseObject, }) {
return __awaiter(this, arguments, void 0, function* ({ dbContext, dbFullName, tableName, identifierColumnName, identifierValue, forceLocal, whereClauseObject, targetIds, }) {
try {
const isMaster = forceLocal
? true
@@ -33,7 +33,11 @@ function deleteDbEntry(_a) {
*/
let query = `DELETE FROM ${isMaster && !dbFullName ? "" : `\`${dbFullName}\`.`}\`${tableName}\``;
let values = [];
if (whereClauseObject) {
if (targetIds) {
query += ` WHERE id IN (${targetIds.map((id) => "?").join(",")})`;
values = targetIds;
}
else if (whereClauseObject) {
query += ` ${whereClauseObject.clause}`;
values.push(...(whereClauseObject.params || []));
}