@awspilot/dynamodb

Issue Star Fork
transaction.js
DynamoDB.schema({ TableName: 'demo_table_hash_range', KeySchema: [ {AttributeName: 'partitionKey' }, {AttributeName: 'sortKey' } ] }) // experimental support for transactions available from version 2.x DynamoDB .transact() .table('demo_table_hash_range') // .insert() does not support .if(), it expects that item does not exist .insert( { partitionKey: 'insert', sortKey: new Date().getTime(), } ) .table('demo_table_hash_range') .if('active').eq(true) // eq, lt, le, gt, ge, ne .if('price').between(7,9) .if('price').not().between(91,95) .if('price').not().in([1,3,5,7,9]) .if('description').begins_with("hello") .if('description').not().contains('discount') .if('me-no-exist').not().exists() .if('logs[1].date').between('2019-11-01', '2020-01-01') .insert_or_replace({ partitionKey: 'insert_or_replace', sortKey: 1, active: true, price: 7.99, description: "hello item", logs: [ { date: '2019-12-02', }, { date: '2019-12-01', }, ], random: Math.random() }) .table('demo_table_hash_range') .replace( { partitionKey: 'replace', sortKey: 1, } ) .table('demo_table_hash_range') .insert_or_update( { partitionKey: 'demo_insert_or_update', sortKey: new Date().getTime(), boolean: true }) .table('demo_table_hash_range') .where('partitionKey').eq('update') .where('sortKey').eq(1) //.if('someobject.someattribute').not().exists() .update( { mynumber: Math.random() } ) .table('demo_table_hash_range') .where('partitionKey').eq('delete') .where('sortKey').eq(1) // .if('pending_delete').eq(true) .delete() .write(function( err, data ) { console.log( err, data ) });