Updates
This commit is contained in:
@@ -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 {};
|
||||
|
||||
@@ -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 || []));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user