document_client 2.0.0 document_client: ^2.0.0 copied to clipboard
The DynamoDB document client simplifies working with items. It uses native Dart types as input parameters, as well as converts response data to native Dart types.
import 'dart:convert';
import 'package:document_client/document_client.dart';
void main() async {
final dc = DocumentClient(region: 'eu-west-1');
final getResponse = await dc.get(
tableName: 'MyTable',
key: {'Car': 'DudeWheresMyCar'},
);
print(jsonEncode(getResponse.item));
// e.g. { "wheels": 24, "units": "inch" }
final batchGetResponse = await dc.batchGet(
requestItems: {
'Table-1': KeysAndProjection(
keys: [
{
'HashKey': 'hashkey',
'NumberRangeKey': 1,
}
],
),
'Table-2': KeysAndProjection(
keys: [
{
'foo': 'bar',
}
],
),
},
);
print(jsonEncode(batchGetResponse.responses));
}