Updates
This commit is contained in:
@@ -27,6 +27,7 @@ type Param<T extends { [k: string]: any } = any> = {
|
||||
debug?: boolean;
|
||||
dbConfig?: ConnectionConfig;
|
||||
whereClauseObject?: DsqlCrudParamWhereClause;
|
||||
targetIds?: (string | number)[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -49,6 +50,7 @@ export default async function updateDbEntry<
|
||||
debug,
|
||||
dbConfig,
|
||||
whereClauseObject,
|
||||
targetIds,
|
||||
}: Param<T>): Promise<APIResponseObject<PostInsertReturn>> {
|
||||
/**
|
||||
* Check if data is valid
|
||||
@@ -142,7 +144,10 @@ export default async function updateDbEntry<
|
||||
isMaster && !dbFullName ? "" : `\`${dbFullName}\`.`
|
||||
}\`${tableName}\` SET ${updateKeyValueArray.join(",")}`;
|
||||
|
||||
if (whereClauseObject) {
|
||||
if (targetIds) {
|
||||
query += ` WHERE id IN (${targetIds.map((id) => "?").join(",")})`;
|
||||
updateValues = targetIds;
|
||||
} else if (whereClauseObject) {
|
||||
query += ` ${whereClauseObject.clause}`;
|
||||
updateValues.push(...(whereClauseObject.params || []));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user