Skip to content

Commit

Permalink
fix: verify the truthiness of sk & remove empty space
Browse files Browse the repository at this point in the history
  • Loading branch information
SajidHamza9 authored and MarioArnt committed Jan 30, 2024
1 parent e52a163 commit 7926224
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/base-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default abstract class Model<T> {
private isValidItem(item: unknown): item is T {
try {
this.pkValue(item as T);
if (this.sk != null) {
if (!!this.sk) {
this.skValue(item as T);
}
return true;
Expand Down Expand Up @@ -646,14 +646,14 @@ export default abstract class Model<T> {
(items.delete as SimpleKey[]).forEach(hashKey => {
writeRequests.push({
DeleteRequest: {
Key: { [String(this.pk)]: hashKey }
Key: { [this.pk as string]: hashKey }
}
});
})
} else {
items.delete.forEach(item => {
const pk = this.pkValue(item as T);
const sk = this.sk != null ? this.skValue(item as T) : undefined;
const sk = !!this.sk ? this.skValue(item as T) : undefined;
writeRequests.push({
DeleteRequest: {
Key: this.buildKeys(pk, sk)
Expand Down Expand Up @@ -702,12 +702,4 @@ export default abstract class Model<T> {
async batchDelete(items: Keys | T[], options?: Partial<BatchWriteCommandInput>): Promise<BatchWriteCommandOutput[]> {
return this.batchWrite({ put: [], delete: items }, options);
}
}








}

0 comments on commit 7926224

Please sign in to comment.