Unparsed Response Object For BatchGet #536
-
I have an array of Thus far, this has been my (suboptimal) approach, but it requires sending hundreds of API requests Much more preferable would be to use the let batch = {}
await Account.get({id: accountId}, {batch})
await User.get({id: userId}, {batch})
let results = await table.batchGet(batch) However, the response is completely untyped and looks like a response straight from DynamoDB. I do not want to write a type guard, as the schema is quite complicated, and a type guard would be difficult to maintain. Does the lib provide some elegant mechanism to type check such responses? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Add
as params to the batchGet. Can also use hidden:true to suppress hidden fields. |
Beta Was this translation helpful? Give feedback.
-
Two suggestions: add {log: true} so you can see the actual command being executed. Create a debug.ts that replicates the issue so can can investigate. |
Beta Was this translation helpful? Give feedback.
-
Great you figured it out. Yes, you need a schema to be able to parse the response. You wont get a batch response typed -- as the return data types are unknown at dev time. |
Beta Was this translation helpful? Give feedback.
I figured out the issue, I wasn't passing the model to the table: