Skip to content

Commit

Permalink
fix: creation of update expression duplicated remove segment
Browse files Browse the repository at this point in the history
  • Loading branch information
benhutchins committed Sep 14, 2023
1 parent 33bf76e commit d21bfe4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/query/update-item-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export function getUpdateItemInput<T extends Table>(record: T, params?: UpdateIt
updateExpression += 'ADD ' + adds.join(', ')
}

if (removes.length > 0) {
if (deletes.length > 0) {
if (updateExpression.length > 0) {
updateExpression += ' '
}

updateExpression += 'REMOVE ' + removes.join(', ')
updateExpression += 'DELETE ' + deletes.join(', ')
}

if (removes.length > 0) {
Expand Down
9 changes: 0 additions & 9 deletions src/tables/properties.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { type BinarySetAttributeValue } from 'aws-sdk/clients/dynamodb'
import { type Table } from '../table'

export type TableProperty<T> = Exclude<keyof T, keyof Table>

type KeyOfType<T, V> = keyof {
[P in keyof T as T[P] extends V ? P : never]: any
}

export type SetValue = string[] | Array<bigint | number> | BinarySetAttributeValue[] | null | undefined

export type SetTableProperty<T> = KeyOfType<T, SetValue>

export type TableProperties<T> = {
[key in TableProperty<T>]?: T[key]
}

0 comments on commit d21bfe4

Please sign in to comment.