Updates
This commit is contained in:
@@ -17,6 +17,7 @@ type Param<T extends {
|
||||
debug?: boolean;
|
||||
dbConfig?: ConnectionConfig;
|
||||
whereClauseObject?: DsqlCrudParamWhereClause;
|
||||
targetIds?: (string | number)[];
|
||||
};
|
||||
/**
|
||||
* # Update DB Function
|
||||
@@ -24,5 +25,5 @@ type Param<T extends {
|
||||
*/
|
||||
export default function updateDbEntry<T extends {
|
||||
[k: string]: any;
|
||||
} = any>({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, debug, dbConfig, whereClauseObject, }: Param<T>): Promise<APIResponseObject<PostInsertReturn>>;
|
||||
} = any>({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, debug, dbConfig, whereClauseObject, targetIds, }: Param<T>): Promise<APIResponseObject<PostInsertReturn>>;
|
||||
export {};
|
||||
|
||||
@@ -24,7 +24,7 @@ const grab_parsed_value_1 = __importDefault(require("./grab-parsed-value"));
|
||||
* @description
|
||||
*/
|
||||
function updateDbEntry(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, debug, dbConfig, whereClauseObject, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, forceLocal, debug, dbConfig, whereClauseObject, targetIds, }) {
|
||||
var _b, _c;
|
||||
/**
|
||||
* Check if data is valid
|
||||
@@ -97,7 +97,11 @@ function updateDbEntry(_a) {
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
let query = `UPDATE ${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 || []));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user