-
Notifications
You must be signed in to change notification settings - Fork 107
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
5 changed files
with
168 additions
and
166 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 |
---|---|---|
@@ -1,38 +1,39 @@ | ||
var db = require('../db'); | ||
var db = require('../db') | ||
|
||
module.exports = function updateTimeToLive(store, data, cb) { | ||
var key = data.TableName, | ||
TimeToLiveSpecification = data.TimeToLiveSpecification, | ||
tableDb = store.tableDb, | ||
returnValue; | ||
module.exports = function updateTimeToLive (store, data, cb) { | ||
var key = data.TableName, | ||
TimeToLiveSpecification = data.TimeToLiveSpecification, | ||
tableDb = store.tableDb, | ||
returnValue | ||
|
||
store.getTable(key, false, function(err, table) { | ||
if (err) return cb(err) | ||
store.getTable(key, false, function (err, table) { | ||
if (err) return cb(err) | ||
|
||
if (TimeToLiveSpecification.Enabled) { | ||
if (table.TimeToLiveDescription && table.TimeToLiveDescription.TimeToLiveStatus === 'ENABLED') { | ||
return cb(db.validationError('TimeToLive is already enabled')) | ||
} | ||
table.TimeToLiveDescription = { | ||
AttributeName: TimeToLiveSpecification.AttributeName, | ||
TimeToLiveStatus: 'ENABLED', | ||
} | ||
returnValue = TimeToLiveSpecification | ||
} else { | ||
if (table.TimeToLiveDescription == null || table.TimeToLiveDescription.TimeToLiveStatus === 'DISABLED') { | ||
return cb(db.validationError('TimeToLive is already disabled')) | ||
} | ||
if (TimeToLiveSpecification.Enabled) { | ||
if (table.TimeToLiveDescription && table.TimeToLiveDescription.TimeToLiveStatus === 'ENABLED') { | ||
return cb(db.validationError('TimeToLive is already enabled')) | ||
} | ||
table.TimeToLiveDescription = { | ||
AttributeName: TimeToLiveSpecification.AttributeName, | ||
TimeToLiveStatus: 'ENABLED', | ||
} | ||
returnValue = TimeToLiveSpecification | ||
} | ||
else { | ||
if (table.TimeToLiveDescription == null || table.TimeToLiveDescription.TimeToLiveStatus === 'DISABLED') { | ||
return cb(db.validationError('TimeToLive is already disabled')) | ||
} | ||
|
||
table.TimeToLiveDescription = { | ||
TimeToLiveStatus: 'DISABLED', | ||
} | ||
returnValue = {Enabled: false} | ||
} | ||
table.TimeToLiveDescription = { | ||
TimeToLiveStatus: 'DISABLED', | ||
} | ||
returnValue = { Enabled: false } | ||
} | ||
|
||
tableDb.put(key, table, function(err) { | ||
if (err) return cb(err) | ||
tableDb.put(key, table, function (err) { | ||
if (err) return cb(err) | ||
|
||
cb(null, {TimeToLiveSpecification: returnValue}) | ||
}) | ||
cb(null, { TimeToLiveSpecification: returnValue }) | ||
}) | ||
}) | ||
} |
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
Oops, something went wrong.