function Message() { this.dynamoDB = new AWS.DynamoDB.DocumentClient({ region: config.REGION, endpoint: config.DYNAMODB_ENDPOINT }); this.tableName = `${config.ENV_NAME}_Messages`; }
it("throws error when operation is not supported", async () => { expect( () => new DynamoDbItemReader( "BOOM", new AWS.DynamoDB.DocumentClient(), dynamoDbParams ) ).toThrow( "Unsupported DynamoDB operation! Supported operations are SCAN and QUERY." ); });
it("generates next object", async () => { documentClient.scan.mockImplementation(yields({ Items: ["Foo"] })); const reader = new DynamoDbItemReader( "SCAN", new AWS.DynamoDB.DocumentClient(), dynamoDbParams ); const next = await reader.next(); expect(next).toEqual({ item: "Foo", cursor: { index: 0 }, finished: true }); });
(() => { let _cache; let conf = config.get('CACHE:DDB'); return () => { if (_cache === undefined) { _cache = conf && conf.TABLE && !conf.DISABLED ? new AWS.DynamoDB() : null; } return _cache; }; })()
function exportSchema(tableName, file, region, endpoint) { const dynamoDb = new AWS.DynamoDB({ region }); if (endpoint) dynamoDb.endpoint = endpoint; return dynamoDb.describeTable({ TableName: tableName }).promise() .then(data => { const table = data.Table; const file2 = file || sanitizeFilename(tableName + '.dynamoschema'); return fs.writeFileAsync(file2, JSON.stringify(table, null, 2)) }); }
const parseRecord = (record, imageType) => { if (!(imageType in record.dynamodb)) { return null } return AWS.DynamoDB.Converter.output({ M: record.dynamodb[imageType] }) }
get jsonNewImage() { return AWS.DynamoDB.Converter.unmarshall(this.newImage); }
const listTables = function (limit = 100) { const ddb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }); return ddb.listTables({ Limit: limit }).promise(); }
constructor(tableName) { this.tableName = tableName; this.documentClient = new AWS.DynamoDB.DocumentClient(); }
function User() { this.saltRounds = 10; this.dynamoDB = new AWS.DynamoDB.DocumentClient({ region: config.REGION, endpoint: config.DYNAMODB_ENDPOINT }); this.tableName = `${config.ENV_NAME}_Users`; }
it("throws error when operation is not supported", async () => { expect( () => new DynamoDbItemReader( "BOOM", new AWS.DynamoDB.DocumentClient(), dynamoDbParams ) ).toThrow( "Unsupported DynamoDB operation! Supported operations are SCAN and QUERY." ); });
it("generates next object", async () => { documentClient.scan.mockImplementation(yields({ Items: ["Foo"] })); const reader = new DynamoDbItemReader( "SCAN", new AWS.DynamoDB.DocumentClient(), dynamoDbParams ); const next = await reader.next(); expect(next).toEqual({ item: "Foo", cursor: { index: 0 }, finished: true }); });
constructor(tableName) { this.tableName = tableName; this.documentClient = new AWS.DynamoDB.DocumentClient(); }