Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var util = require('util'); | ||
var _ = require('underscore'); | ||
var items = module.exports = {}; | ||
var types = require('./types'); | ||
var config = require('./config')(); | ||
|
||
items.putItems = function(items, opts, cb) { | ||
if(!cb) { cb = opts; opts = {}; } | ||
var table = opts.table || config.table; | ||
var params = { RequestItems: {} }; | ||
params.RequestItems[table] = items.map(function(item) { | ||
return { | ||
PutRequest: { | ||
Item: types.toDynamoTypes(item) | ||
} | ||
}; | ||
}); | ||
config.dynamo.batchWriteItem(params, cb); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
module.exports.test = { | ||
'TableName': 'test', | ||
'AttributeDefinitions': [ | ||
{'AttributeName': 'id', 'AttributeType': 'S'}, | ||
{'AttributeName': 'range', 'AttributeType': 'N'} | ||
], | ||
'KeySchema': [ | ||
{'AttributeName': 'id', 'KeyType': 'HASH'}, | ||
{'AttributeName': 'range', 'KeyType': 'RANGE'} | ||
], | ||
'ProvisionedThroughput': { | ||
'ReadCapacityUnits': 1, | ||
'WriteCapacityUnits': 1 | ||
} | ||
}; | ||
'TableName': 'test', | ||
'AttributeDefinitions': [ | ||
{'AttributeName': 'id', 'AttributeType': 'S'}, | ||
{'AttributeName': 'range', 'AttributeType': 'N'} | ||
], | ||
'KeySchema': [ | ||
{'AttributeName': 'id', 'KeyType': 'HASH'}, | ||
{'AttributeName': 'range', 'KeyType': 'RANGE'} | ||
], | ||
'ProvisionedThroughput': { | ||
'ReadCapacityUnits': 1, | ||
'WriteCapacityUnits': 1 | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var test = require('tap').test; | ||
var s = require('./setup'); | ||
var es = require('event-stream'); | ||
var dyno = s.dyno; | ||
|
||
test('setup', s.setup()); | ||
test('setup table', s.setupTable); | ||
test('putItems', function(t) { | ||
var items = randomItems(10); | ||
|
||
dyno.putItems(items, itemResp); | ||
function itemResp(err, resp) { | ||
t.equal(err, null); | ||
t.deepEqual(resp, { | ||
UnprocessedItems: {} | ||
}); | ||
t.end(); | ||
// dyno.getItem(item, getItem); | ||
} | ||
function getItem(err, resp) { | ||
// t.equal(err, null); | ||
// t.deepEqual(resp, {Item:{id: 'yo', range: 5}}); | ||
// t.end(); | ||
} | ||
}); | ||
test('teardown', s.teardown); | ||
|
||
function randomItems(n) { | ||
var items = []; | ||
for (var i = 0; i < n; i++) { | ||
items.push({ | ||
id: 'id:' + i.toString(), | ||
range: i, | ||
data: (new Array(100)).join(' '), | ||
}); | ||
} | ||
return items; | ||
} |