Skip to content

Commit cd6f9d6

Browse files
Merge pull request #22 from apoorvmalhotra/mapsAndLists
When the -d option is used, for Maps and Lists, the keys of individual items are now converted to lower case.
2 parents e973213 + 1ec7ebe commit cd6f9d6

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/dynamo-backup.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ util.inherits(DynamoBackup, events.EventEmitter);
3838
DynamoBackup.prototype.listTables = function (callback) {
3939
var self = this;
4040
self._fetchTables(null, [], callback);
41-
}
41+
};
4242

4343
DynamoBackup.prototype.backupTable = function (tableName, backupPath, callback) {
4444
var self = this;
@@ -104,7 +104,7 @@ DynamoBackup.prototype.backupTable = function (tableName, backupPath, callback)
104104
}
105105
}
106106
);
107-
}
107+
};
108108

109109
DynamoBackup.prototype.backupAllTables = function (callback) {
110110
var self = this;
@@ -132,13 +132,13 @@ DynamoBackup.prototype.backupAllTables = function (callback) {
132132
callback
133133
);
134134
});
135-
}
135+
};
136136

137137
DynamoBackup.prototype._getBackupPath = function () {
138138
var self = this;
139139
var now = moment.utc();
140140
return self.backupPath || ('DynamoDB-backup-' + now.format('YYYY-MM-DD-HH-mm-ss'));
141-
}
141+
};
142142

143143
DynamoBackup.prototype._copyTable = function (tableName, itemsReceived, callback) {
144144
var self = this;
@@ -153,7 +153,7 @@ DynamoBackup.prototype._copyTable = function (tableName, itemsReceived, callback
153153

154154
self._streamItems(tableName, null, limit, itemsReceived, callback);
155155
});
156-
}
156+
};
157157

158158
DynamoBackup.prototype._streamItems = function fetchItems(tableName, startKey, limit, itemsReceived, callback) {
159159
var self = this;
@@ -180,7 +180,7 @@ DynamoBackup.prototype._streamItems = function fetchItems(tableName, startKey, l
180180
}
181181
self._streamItems(tableName, data.LastEvaluatedKey, limit, itemsReceived, callback);
182182
});
183-
}
183+
};
184184

185185
DynamoBackup.prototype._fetchTables = function (lastTable, tables, callback) {
186186
var self = this;
@@ -217,6 +217,10 @@ DynamoBackup.prototype._formatForDataPipeline = function (item) {
217217
var dataPipelineValueKey = self._getDataPipelineAttributeValueKey(k);
218218
value[dataPipelineValueKey] = v;
219219
value[k] = undefined;
220+
// for MAps and Lists, recurse until the elements are created with the correct case
221+
if(k === 'M' || k === 'L') {
222+
self._formatForDataPipeline(v);
223+
}
220224
});
221225
});
222226
return JSON.stringify(item);
@@ -230,8 +234,9 @@ DynamoBackup.prototype._getDataPipelineAttributeValueKey = function (type) {
230234
case 'M':
231235
case 'L':
232236
case 'NULL':
233-
case 'BOOL':
234237
return type.toLowerCase();
238+
case 'BOOL':
239+
return 'bOOL';
235240
case 'SS':
236241
return 'sS';
237242
case 'NS':
@@ -241,6 +246,6 @@ DynamoBackup.prototype._getDataPipelineAttributeValueKey = function (type) {
241246
default:
242247
throw new Error('Unknown AttributeValue key: ' + type);
243248
}
244-
}
249+
};
245250

246251
module.exports = DynamoBackup;

0 commit comments

Comments
 (0)