dynamodb-backup-restore
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -107,7 +107,7 @@ 'use strict'; | ||
gulp.task('deploy-lambda-event', (cb) => { | ||
let config = { | ||
let config = { | ||
DbTable: argv.dbtable, | ||
DbRegion: argv.dbregion, | ||
LambdaName: argv.lName, | ||
LambdaRegion: argv.lRegion, | ||
LambdaRegion: argv.lRegion, | ||
}; | ||
@@ -129,6 +129,6 @@ | ||
return gulp.src([ | ||
'./tests/*.js' | ||
'./tests/**/*.test.js' | ||
]) | ||
.pipe(jasmine({ | ||
timeout: 40000, | ||
timeout: 1000, | ||
verbose: true, | ||
@@ -135,0 +135,0 @@ integration: true, |
@@ -31,2 +31,3 @@ 'use strict'; | ||
} | ||
console.log('Got key schema ' + JSON.stringify(data.Table.KeySchema)); | ||
return resolve(data.Table.KeySchema); | ||
@@ -48,2 +49,4 @@ }); | ||
var numberOfRecords = 0; | ||
function recursiveCall(params) { | ||
@@ -69,2 +72,4 @@ dynamodb.scan(params, function (err, data) { | ||
numberOfRecords += data.Items.length; | ||
console.log('Retrieved ' + data.Items.length + ' records; total at ' + numberOfRecords + ' records.'); | ||
if (data.LastEvaluatedKey) { | ||
@@ -71,0 +76,0 @@ params.ExclusiveStartKey = data.LastEvaluatedKey; |
@@ -42,2 +42,3 @@ 'use strict'; | ||
else { | ||
console.log('Retrieved stream ARN ' + data.Table.LatestStreamArn); | ||
return resolve(data.Table.LatestStreamArn); | ||
@@ -64,2 +65,3 @@ } | ||
}); | ||
console.log("Retrieved stream shards " + shardIds); | ||
return resolve(shardIds); | ||
@@ -66,0 +68,0 @@ } |
@@ -6,3 +6,3 @@ 'use strict'; | ||
class VersionList { | ||
constructor(config) { | ||
constructor(config, versionReaderFunc) { | ||
this.RestoreTime = config.RestoreTime; | ||
@@ -12,6 +12,7 @@ this.S3Bucket = config.S3Bucket; | ||
this.S3Region = config.S3Region; | ||
this.VersionReaderFunc = versionReaderFunc === undefined ? this.getAllVersions : versionReaderFunc; | ||
} | ||
getVersions() { | ||
return this.getAllVersions() | ||
return this.VersionReaderFunc() | ||
.then(allVersionList => { | ||
@@ -71,10 +72,10 @@ return this.versionListCreatedBeforeGivenTime(allVersionList) | ||
return new Promise(resolve => { | ||
function filterData(versions) { | ||
return versions.filter(version => { | ||
let diff = this.RestoreTime - new Date(version.LastModified); | ||
return (diff >= 0) ? true : false; | ||
}); | ||
} | ||
let filteredData = filterData.call(this, allObjectVersions); | ||
let filteredData = allObjectVersions.filter(version => { | ||
if (this.RestoreTime === undefined) { | ||
return true; | ||
} | ||
return (this.RestoreTime - new Date(version.LastModified)) >= 0; | ||
}); | ||
let newData = {}; | ||
@@ -87,2 +88,3 @@ | ||
}); | ||
return resolve(newData); | ||
@@ -95,3 +97,3 @@ }); | ||
allObjectVersions.forEach(data => { | ||
let diff = this.RestoreTime - new Date(data.LastModified); | ||
let diff = this.RestoreTime === undefined ? -1 : (this.RestoreTime - new Date(data.LastModified)); | ||
if (diff < 0 && !(data.Key in versionList)) { | ||
@@ -98,0 +100,0 @@ versionList[data.Key] = data; |
@@ -22,3 +22,2 @@ 'use strict'; | ||
.then(data => { | ||
console.log('Sending this data to Dynamo: ' + JSON.stringify(data, null, 2)); | ||
console.timeEnd('BuildVersionListFromS3'); | ||
@@ -25,0 +24,0 @@ console.time('PushToDynamo'); |
{ | ||
"name": "dynamodb-backup-restore", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "NPM package for Backup and Restore AWS DynamoDB", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Purple-Unicorns/DynamoDbBackUp", |
var backup = require('./../lib/backup'); | ||
describe('test', function () { | ||
it('should return true', function () { | ||
expect(true).toBe(true) | ||
describe('Test', function () { | ||
it('is still to be implemented', function () { | ||
expect(true).toBe(true); | ||
}); | ||
}); | ||
}); |
66795
23
1571