dynamodb-toolbox
Advanced tools
Comparing version 0.2.0-beta to 0.2.0-beta.1
@@ -227,2 +227,37 @@ const { Table, Entity } = require('../index') | ||
// Adding this for regression testing | ||
it('Non-Key Index Generated on Delete #74', async () => { | ||
const FoosTable = new Table({ | ||
name: 'test-table', | ||
partitionKey: 'pk', | ||
sortKey: 'sk', | ||
indexes: { | ||
'GSI-1': { partitionKey: 'gsi1pk', sortKey: 'gsi1sk' }, | ||
}, | ||
DocumentClient, | ||
}); | ||
const Foos = new Entity({ | ||
name: 'Foo', | ||
table: FoosTable, | ||
timestamps: true, | ||
attributes: { | ||
pk: { hidden: true, partitionKey: true, default: (data) => (`FOO#${data.id}`) }, | ||
sk: { hidden: true, sortKey: true, default: (data) => (`FOO#${data.id}`) }, | ||
// This next `default` gets executed on delete() and fails with "Cannot read property 'tenant' of undefined" | ||
gsi1pk: { hidden: true, default: (data) => (`TENANT#${data.meta.tenant}`) }, | ||
gsi1sk: { hidden: true, default: (data) => (`FOO#${data.id}`) }, | ||
id: { required: 'always' }, | ||
meta: { type: 'map', required: 'always' }, | ||
__context__: { hidden: true }, | ||
}, | ||
}); | ||
const key = { id: 'xyz' } | ||
let result = Foos.deleteParams(key) // Fails with v0.2.0-beta. Fine with v0.2.0-alpha | ||
expect(result).toEqual({ TableName: 'test-table', Key: { pk: 'FOO#xyz', sk: 'FOO#xyz' } }) | ||
}) | ||
}) |
@@ -34,5 +34,45 @@ // Bootstrap testing | ||
it('Non-Key Index Generated on Delete #74', async () => { | ||
const FoosTable = new Table({ | ||
name: 'test-table', | ||
partitionKey: 'pk', | ||
sortKey: 'sk', | ||
indexes: { | ||
'GSI-1': { partitionKey: 'gsi1pk', sortKey: 'gsi1sk' }, | ||
}, | ||
DocumentClient, | ||
}); | ||
const Foos = new Entity({ | ||
name: 'Foo', | ||
table: FoosTable, | ||
timestamps: true, | ||
attributes: { | ||
pk: { hidden: true, partitionKey: true, default: (data) => (`FOO#${data.id}`) }, | ||
sk: { hidden: true, sortKey: true, default: (data) => (`FOO#${data.id}`) }, | ||
// This next `default` gets executed on delete() and fails with "Cannot read property 'tenant' of undefined" | ||
gsi1pk: { hidden: true, default: (data) => (`TENANT#${data.meta.tenant}`) }, | ||
gsi1sk: { hidden: true, default: (data) => (`FOO#${data.id}`) }, | ||
id: { required: 'always' }, | ||
meta: { type: 'map', required: 'always' }, | ||
__context__: { hidden: true }, | ||
}, | ||
}); | ||
it('Function default dependency issue #68', async () => { | ||
const foo = { | ||
id: 'xyz', | ||
meta: { tenant: 'abc' }, | ||
}; | ||
await Foos.put(foo); | ||
const key = { id: foo.id }; | ||
await Foos.delete(key); // Fails with v0.2.0-beta. Fine with v0.2.0-alpha | ||
}) | ||
it.skip('Function default dependency issue #68', async () => { | ||
const { randomBytes } = require('crypto') | ||
@@ -39,0 +79,0 @@ |
@@ -38,5 +38,9 @@ 'use strict' | ||
} else { | ||
map[attr] = map[attr](map) | ||
if (schema[attr].alias) map[schema[attr].alias] = map[attr] | ||
if (schema[attr].map) map[schema[attr].map] = map[attr] | ||
try { | ||
map[attr] = map[attr](map) | ||
if (schema[attr].alias) map[schema[attr].alias] = map[attr] | ||
if (schema[attr].map) map[schema[attr].map] = map[attr] | ||
} catch(e) { | ||
// TODO: Find a better way to prevent this for missing fields | ||
} | ||
return map | ||
@@ -43,0 +47,0 @@ } |
{ | ||
"name": "dynamodb-toolbox", | ||
"version": "0.2.0-beta", | ||
"version": "0.2.0-beta.1", | ||
"description": "A simple set of tools for working with Amazon DynamoDB and the DocumentClient.", | ||
@@ -5,0 +5,0 @@ "author": "Jeremy Daly <jeremy@jeremydaly.com>", |
Sorry, the diff of this file is too big to display
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
407693
8171