import * as AWS from 'aws-sdk' ; import { DynamoDB } from 'aws-sdk' ; class DynamoToPromise { constructor ( private dynamo ) { } public async scan ( params ) { return new Promise ( ( resolve , reject ) => { this . dynamo . scan ( params , ( err , data ) => { if ( err ) { return reject ( err ) ; } return resolve ( data ) ; } ) ; } ) ; } public async batchGet ( params ) { return new Promise ( ( resolve , reject ) => { this . dynamo . batchGet ( params , ( err , data ) => { if ( err ) { return reject ( err ) ; } return resolve ( data ) ; } ) ; } ) ; } public async getItem ( params ) { return new Promise ( ( resolve , reject ) => { this . dynamo . get ( params , ( err , data ) => { if ( err ) { return reject ( err ) ; } return resolve ( data ) ; } ) ; } ) ; } public async put ( params ) { return new Promise ( ( resolve , reject ) => { this . dynamo . put ( params , ( err , data ) => { if ( err ) { return reject ( err ) ; } return resolve ( data ) ; } ) ; } ) ; } public async update ( params ) { return new Promise ( ( resolve , reject ) => { this . dynamo . update ( params , ( err , data ) => { if ( err ) { return reject ( err ) ; } return resolve ( data ) ; } ) ; } ) ; } public async delete ( params ) { return new Promise ( ( resolve , reject ) => { this . dynamo . delete ( params , ( err , data ) => { if ( err ) { return reject ( err ) ; } return resolve ( data ) ; } ) ; } ) ; } public async query ( params ) { return new Promise ( ( resolve , reject ) => { this . dynamo . query ( params , ( err , data ) => { if ( err ) { return reject ( err ) ; } return resolve ( data ) ; } ) ; } ) ; } public async batchWrite ( params ) { return new Promise ( ( resolve , reject ) => { this . dynamo . batchWrite ( params , ( err , data ) => { if ( err ) { return reject ( err ) ; } return resolve ( data ) ; } ) ; } ) ; } } export default DynamoToPromise ;