MCPcopy Create free account
hub / github.com/Parana-Games/tinymo / build

Method build

src/batch-write.ts:32–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 }
31
32 build(): BatchWriteCommandInput {
33 const puts = this.batchWriteItems.filter((p): p is Put => p instanceof Put)
34 const deletes = this.batchWriteItems.filter((p): p is Delete => p instanceof Delete)
35 const tableNames = [...puts, ...deletes].map(p => p.tableName).filter((v, i, a) => a.indexOf(v) === i)
36
37 const input: BatchWriteCommandInput = {
38 RequestItems: tableNames.reduce((acc, tableName) => {
39 const putRequests = puts.filter(p => p.tableName === tableName).map(p => { return { PutRequest: { Item: p.build().Item } } })
40 const deleteRequests = deletes.filter(p => p.tableName === tableName).map(p => { return { DeleteRequest: { Key: p.key } } })
41 acc[tableName] = [...putRequests, ...deleteRequests]
42 return acc
43 }, {} as { [key: string]: WriteRequest[] })
44 }
45
46 if (this.returnConsumedCapacity) input.ReturnConsumedCapacity = this.returnConsumedCapacity
47 if (this.returnItemCollectionMetrics) input.ReturnItemCollectionMetrics = this.returnItemCollectionMetrics
48
49 return input
50 }
51}

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected