@awspilot/dynamodb

Issue Star Fork
batch_insert.js
batch_insert_from_array.js
batch_insert_sql.js
DynamoDB .batch() .table('demo_table_hash_range') .put({ partitionKey: 'pk1', sortKey: 1, active: false }) .put({ partitionKey: 'pk1', sortKey: 2, active: false }) .put({ partitionKey: 'pk2', sortKey: 1, active: true }) .del({ partitionKey: 'pk3', sortKey: 1 }) .write(function( err, data ) { console.log( err, data ) });
var list = [ { partitionKey: 'pk1', sortKey: 1, active: false }, { partitionKey: 'pk1', sortKey: 2, active: false }, { partitionKey: 'pk2', sortKey: 1, active: true } ] var ddb = DynamoDB.batch().table('demo_table_hash_range') list.forEach(function( item ) { ddb.put( item ) }) ddb.write(function( err, data ) { console.log( err, data ) });
// if there are multiple items in VALUES then batchWriteItem is performed // insert using VALUES does not currently support StringSet or NumberSet DynamoDB.query(` INSERT INTO demo_table_hash_range VALUES ({ partitionKey: 'pk1', sortKey: 1, active: false }), ({ partitionKey: 'pk1', sortKey: 2, active: false }), ({ partitionKey: 'pk2', sortKey: 1, active: true }) `, function( err, data ) { console.log( err, data ) });