There are different requests you can use to read from or write to different tables.
General
Creation
Multi-model requests are created with the new keyword.
You can provide a DynamoDB client instance when creating a new multi model request:new BatchGetRequest(Person, myDynamoDBClient)
Params
Every request instance contains the public params property where all params for the request are written to. You might want to use it for debugging purpose but are also able to write on it (eg. non-covered features).
Consumed Capacity
You might want to receive the consumed capacity which can be achieved by applying the returnConsumedCapacity('INDEXES' | 'TOTAL') method and the usage of execFullResponse() instead of exec().
Execution
All requests provide at least two execution methods:
exec() returns a promise which will resolve to the requested items or void if no items were requested
execFullResponse() returns a promise which will resolve to the full response DynamoDB returns, but response.Items are still mapped for you.
BatchGet
batch-get-request.example.ts
import { BatchGetRequest, BatchGetResponse } from'@shiftcoders/dynamo-easy'import { AnotherModel, Person } from'../models'constkeysToFetch:Array<Partial<Person>> = [{ id:'vogelsw' }]constotherKeysToFetch:Array<Partial<AnotherModel>> = [{ propA:'Foo', propB:'Bar' }]newBatchGetRequest().forModel(Person, keysToFetch).forModel(AnotherModel, otherKeysToFetch).exec().then((result:BatchGetResponse) => {console.log('items fetched from example table',result.tableNameOfExampleModel)console.log('items fetched from another table',result.tableNameOfAnotherModel) })
Execute transactional write operations by providing one or multiple transact items (TransactConditionCheck, TransactDelete, TransactPut, TransactUpdate).