UNPKG

@env0/dynamo-easy

Version:

DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.

27 lines 906 B
/** * @module expression */ import { attributeNameReplacer } from './attribute-name-replacer.function'; /** * @hidden */ export const BRACED_INDEX_REGEX = /\[(\d+)]/g; /** * Creates a unique attribute value placeholder name to use in the expression * * @returns {string} The unique attribute value placeholder name in respect to the given existing value names (no duplicates allowed) * @hidden */ export function uniqueAttributeValueName(key, existingValueNames) { key = key.replace(/\./g, '__').replace(BRACED_INDEX_REGEX, attributeNameReplacer); let potentialName = `:${key}`; let idx = 1; if (existingValueNames && existingValueNames.length) { while (existingValueNames.includes(potentialName)) { idx++; potentialName = `:${key}_${idx}`; } } return potentialName; } //# sourceMappingURL=unique-attribute-value-name.function.js.map