Updates
This commit is contained in:
@@ -18,6 +18,7 @@ type Param<T extends { [k: string]: any } = any, K extends string = string> = {
|
||||
identifierValue?: string | number;
|
||||
forceLocal?: boolean;
|
||||
whereClauseObject?: DsqlCrudParamWhereClause;
|
||||
targetIds?: (string | number)[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,7 @@ export default async function deleteDbEntry<
|
||||
identifierValue,
|
||||
forceLocal,
|
||||
whereClauseObject,
|
||||
targetIds,
|
||||
}: Param<T, K>): Promise<APIResponseObject<PostInsertReturn>> {
|
||||
try {
|
||||
const isMaster = forceLocal
|
||||
@@ -52,7 +54,10 @@ export default async function deleteDbEntry<
|
||||
|
||||
let values: any[] = [];
|
||||
|
||||
if (whereClauseObject) {
|
||||
if (targetIds) {
|
||||
query += ` WHERE id IN (${targetIds.map((id) => "?").join(",")})`;
|
||||
values = targetIds;
|
||||
} else if (whereClauseObject) {
|
||||
query += ` ${whereClauseObject.clause}`;
|
||||
values.push(...(whereClauseObject.params || []));
|
||||
} else if (identifierColumnName && identifierValue) {
|
||||
|
||||
@@ -1559,6 +1559,7 @@ export type DsqlCrudParam<
|
||||
deleteKeyValues?: SQLDeleteData[];
|
||||
deleteKeyValuesOperator?: "AND" | "OR";
|
||||
targetId?: string | number;
|
||||
targetIds?: (string | number)[];
|
||||
targetValue?: string | number;
|
||||
targetField?: keyof T;
|
||||
query?: DsqlCrudQueryObject<T, K>;
|
||||
@@ -2945,6 +2946,7 @@ export type APIPathsQuery<
|
||||
| "count"
|
||||
| "countOnly"
|
||||
| "targetId"
|
||||
| "targetIds"
|
||||
| "targetField"
|
||||
| "targetValue"
|
||||
| "tableSchema"
|
||||
|
||||
@@ -24,6 +24,7 @@ export default async function dsqlCrud<
|
||||
sanitize,
|
||||
targetField,
|
||||
targetId,
|
||||
targetIds,
|
||||
dbFullName,
|
||||
deleteData,
|
||||
batchData,
|
||||
@@ -100,7 +101,15 @@ export default async function dsqlCrud<
|
||||
case "delete":
|
||||
let res: PostInsertReturn;
|
||||
|
||||
if (whereClauseObject) {
|
||||
if (targetIds) {
|
||||
const DELETE_RES = await deleteDbEntry({
|
||||
tableName: table,
|
||||
dbFullName,
|
||||
targetIds,
|
||||
});
|
||||
|
||||
return DELETE_RES;
|
||||
} else if (whereClauseObject) {
|
||||
const DELETE_RES = await deleteDbEntry({
|
||||
whereClauseObject,
|
||||
tableName: table,
|
||||
|
||||
Reference in New Issue
Block a user