electrodb
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -141,2 +141,6 @@ # Changelog | ||
### Fixed | ||
- In some cases the `find()` and `match()` methods would incorrectly select an index without a complete partition key. This would result in validation exceptions preventing the user from querying if an index definition and provided attribute object aligned improperly. This was fixed and a slightly more robust mechanism for ranking indexes was made. | ||
- In some cases the `find()` and `match()` methods would incorrectly select an index without a complete partition key. This would result in validation exceptions preventing the user from querying if an index definition and provided attribute object aligned improperly. This was fixed and a slightly more robust mechanism for ranking indexes was made. | ||
## [1.6.2] = 2021-01-27 | ||
### Changed | ||
- The methods `create`, `patch`, and `remove` will now refer to primary table keys through parameters via ExpressionAttributeNames when using `attribute_exists()`/`attribute_not_exists()` DynamoDB conditions. Prior to this they were referenced directly which would fail in cases where key names include illegal characters. Parameter implementation change only, non-breaking. |
{ | ||
"name": "electrodb", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,3 +0,3 @@ | ||
const { QueryTypes, MethodTypes, ItemOperations, ExpressionTypes } = require("./types"); | ||
const {AttributeOperationProxy, UpdateOperations} = require("./operations"); | ||
const { QueryTypes, MethodTypes, ItemOperations, ExpressionTypes, TableIndex } = require("./types"); | ||
const {AttributeOperationProxy, UpdateOperations, FilterOperationNames} = require("./operations"); | ||
const {UpdateExpression} = require("./update"); | ||
@@ -137,2 +137,8 @@ const {FilterExpression} = require("./where"); | ||
const attributes = state.getCompositeAttributes(); | ||
const filter = state.query.filter[ExpressionTypes.ConditionExpression]; | ||
const {pk, sk} = entity._getPrimaryIndexFieldNames(); | ||
filter.unsafeSet(FilterOperationNames.exists, pk); | ||
if (sk) { | ||
filter.unsafeSet(FilterOperationNames.exists, sk); | ||
} | ||
return state | ||
@@ -193,2 +199,8 @@ .setMethod(MethodTypes.delete) | ||
const attributes = state.getCompositeAttributes(); | ||
const filter = state.query.filter[ExpressionTypes.ConditionExpression]; | ||
const {pk, sk} = entity._getPrimaryIndexFieldNames(); | ||
filter.unsafeSet(FilterOperationNames.notExists, pk); | ||
if (sk) { | ||
filter.unsafeSet(FilterOperationNames.notExists, sk); | ||
} | ||
return state | ||
@@ -218,2 +230,8 @@ .setMethod(MethodTypes.put) | ||
const attributes = state.getCompositeAttributes(); | ||
const filter = state.query.filter[ExpressionTypes.ConditionExpression]; | ||
const {pk, sk} = entity._getPrimaryIndexFieldNames(); | ||
filter.unsafeSet(FilterOperationNames.exists, pk); | ||
if (sk) { | ||
filter.unsafeSet(FilterOperationNames.exists, sk); | ||
} | ||
return state | ||
@@ -220,0 +238,0 @@ .setMethod(MethodTypes.update) |
@@ -456,2 +456,7 @@ const {AttributeTypes, ItemOperations, AttributeProxySymbol, BuilderTypes} = require("./types"); | ||
module.exports = {UpdateOperations, FilterOperations, ExpressionState, AttributeOperationProxy}; | ||
const FilterOperationNames = Object.keys(FilterOperations).reduce((ops, name) => { | ||
ops[name] = name; | ||
return ops; | ||
}, {}); | ||
module.exports = {UpdateOperations, FilterOperations, FilterOperationNames, ExpressionState, AttributeOperationProxy}; |
const {MethodTypes, ExpressionTypes, BuilderTypes} = require("./types"); | ||
const {AttributeOperationProxy, ExpressionState} = require("./operations"); | ||
const {AttributeOperationProxy, ExpressionState, FilterOperations} = require("./operations"); | ||
const e = require("./errors"); | ||
@@ -46,2 +46,18 @@ | ||
// applies operations without verifying them against known attributes. Used internally for key conditions. | ||
unsafeSet(operation, name, ...values) { | ||
const {template} = FilterOperations[operation] || {}; | ||
if (template === undefined) { | ||
throw new Error(`Invalid operation: "${operation}". Please report`); | ||
} | ||
const names = this.setName({}, name, name); | ||
if (values.length) { | ||
for (const value of values) { | ||
this.setValue(name, value); | ||
} | ||
} | ||
const condition = template({}, name.expression, names.prop, ...values); | ||
this.add(condition); | ||
} | ||
build() { | ||
@@ -48,0 +64,0 @@ return this.expression; |
Sorry, the diff of this file is too big to display
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
563033
8047