Skip to content

Commit 09d3eed

Browse files
committed
fix: watch property in model does not support maps
1 parent 72e95e7 commit 09d3eed

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

packages/backend/src/graphql/admin/mutations/patch-gsi-rows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const patchGsiRows: AdminMutationResolvers['patchGsiRows'] = async (
9191
* We update with a concurrency of 10 to prevent overloading the partition
9292
* and server
9393
*/
94-
const updateLimit = pLimit(100)
94+
const updateLimit = pLimit(10)
9595

9696
await Promise.all(
9797
/**

packages/backend/src/models/dynamodb/__tests__/table-row/functions.itest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ describe('dynamodb table row functions', () => {
543543
const updatedRow = await patchTableRow({
544544
tableId: dummyTable.id,
545545
rowId: row.rowId,
546-
patchData: { [dummyColumnIds[0]]: '123' },
546+
patchData: { set: { [dummyColumnIds[0]]: '123' } },
547547
})
548548
expect(updatedRow.updatedAt).toBeGreaterThan(row.updatedAt)
549549
})

packages/backend/src/models/dynamodb/table-row/model.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,19 @@ export const TableRow = new Entity(
3636
},
3737
updatedAt: {
3838
type: 'number',
39-
watch: ['data'],
39+
watch: '*',
4040
required: true,
4141
default: () => Date.now(),
42-
set: () => Date.now(),
42+
set: (_, changeObject) => {
43+
/**
44+
* We only update the updatedAt if the data is being updated
45+
* This is to prevent updating the updatedAt when patching GSI
46+
*/
47+
const keys = Object.keys(changeObject)
48+
if (keys.some((key) => key === 'data' || key.startsWith('data.'))) {
49+
return Date.now()
50+
}
51+
},
4352
},
4453
skString1: {
4554
type: 'string',

0 commit comments

Comments
 (0)