dynamodb-admin
Advanced tools
Comparing version 1.5.0 to 1.6.0
10
index.js
@@ -6,3 +6,3 @@ const express = require('express') | ||
const errorhandler = require('errorhandler') | ||
const { serializeKey, unserializeKey } = require('./util') | ||
const { serializeKey, parseKey } = require('./util') | ||
const bodyParser = require('body-parser') | ||
@@ -68,3 +68,3 @@ | ||
return Object.assign({}, item, { | ||
__key: serializeKey(item, description.Table) | ||
__key: serializeKey(item, description.Table.KeySchema) | ||
}) | ||
@@ -99,3 +99,3 @@ }) | ||
TableName, | ||
Key: unserializeKey(req.params.key, result.Table) | ||
Key: parseKey(req.params.key, result.Table) | ||
} | ||
@@ -114,3 +114,3 @@ | ||
TableName, | ||
Key: unserializeKey(req.params.key, result.Table) | ||
Key: parseKey(req.params.key, result.Table) | ||
} | ||
@@ -141,3 +141,3 @@ | ||
TableName, | ||
Key: unserializeKey(req.params.key, result.Table) | ||
Key: parseKey(req.params.key, result.Table) | ||
} | ||
@@ -144,0 +144,0 @@ return getItem(params).then((response) => { |
{ | ||
"name": "dynamodb-admin", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "GUI for DynamoDB. Useful for local development.", | ||
"main": "index.js", | ||
"bin": "./bin/dynamodb-admin.js", | ||
"engines": { | ||
"node": "6.4.0", | ||
"npm": "3.10.3" | ||
}, | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"repository": { | ||
@@ -29,3 +36,6 @@ "type": "git", | ||
"express": "^4.14.0" | ||
}, | ||
"devDependencies": { | ||
"jest-cli": "^15.0.2" | ||
} | ||
} |
34
util.js
@@ -1,23 +0,17 @@ | ||
exports.serializeKey = function (item, table) { | ||
if (table.KeySchema.length === 2) { | ||
return { | ||
[table.KeySchema[0].AttributeName]: item[table.KeySchema[0].AttributeName], | ||
[table.KeySchema[1].AttributeName]: item[table.KeySchema[1].AttributeName] | ||
} | ||
} | ||
return { | ||
id: item.id | ||
} | ||
exports.serializeKey = function (item, KeySchema) { | ||
return KeySchema.reduce((prev, current) => { | ||
return Object.assign({}, prev, { | ||
[current.AttributeName]: item[current.AttributeName] | ||
}) | ||
}, {}) | ||
} | ||
exports.unserializeKey = function (keys, table) { | ||
if (table.KeySchema.length === 2) { | ||
return { | ||
[table.KeySchema[0].AttributeName]: keys.split(',')[0], | ||
[table.KeySchema[1].AttributeName]: typecastKey(table.KeySchema[1].AttributeName, keys.split(',')[1], table) | ||
} | ||
} | ||
return { | ||
id: keys | ||
} | ||
exports.parseKey = function (keys, table) { | ||
const splitKeys = keys.split(',') | ||
return table.KeySchema.reduce((prev, current, index) => { | ||
return Object.assign({}, prev, { | ||
[current.AttributeName]: typecastKey(current.AttributeName, splitKeys[index], table) | ||
}) | ||
}, {}) | ||
} | ||
@@ -24,0 +18,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116066
17
708
1