@karmaniverous/entity-manager
Advanced tools
Comparing version 6.13.0 to 6.13.1
@@ -114,7 +114,10 @@ 'use strict'; | ||
* @param rangeKeyToken - Index range key. | ||
* @param suppressError - Suppress error if no match found. | ||
* | ||
* @returns Index token if found. | ||
* | ||
* @throws `Error` if no match found and `suppressError` is not `true`. | ||
*/ | ||
findIndexToken(hashKeyToken, rangeKeyToken) { | ||
return findIndexToken.findIndexToken(this, hashKeyToken, rangeKeyToken); | ||
findIndexToken(hashKeyToken, rangeKeyToken, suppressError) { | ||
return findIndexToken.findIndexToken(this, hashKeyToken, rangeKeyToken, suppressError); | ||
} | ||
@@ -121,0 +124,0 @@ /** |
@@ -9,9 +9,15 @@ 'use strict'; | ||
* @param rangeKeyToken - Index range key. | ||
* @param suppressError - Suppress error if no match found. | ||
* | ||
* @returns Index token if found. | ||
* | ||
* @throws `Error` if no match found and `suppressError` is not `true`. | ||
*/ | ||
function findIndexToken(entityManager, hashKeyToken, rangeKeyToken) { | ||
return Object.entries(entityManager.config.indexes).find(([, index]) => index.hashKey === hashKeyToken && index.rangeKey === rangeKeyToken)?.[0]; | ||
function findIndexToken(entityManager, hashKeyToken, rangeKeyToken, suppressError) { | ||
const indexToken = Object.entries(entityManager.config.indexes).find(([, index]) => index.hashKey === hashKeyToken && index.rangeKey === rangeKeyToken)?.[0]; | ||
if (!indexToken && !suppressError) | ||
throw new Error(`No index token found for hashKey '${hashKeyToken}' & rangeKey '${rangeKeyToken}'.`); | ||
return indexToken; | ||
} | ||
exports.findIndexToken = findIndexToken; |
@@ -595,6 +595,9 @@ import { EntityMap, TranscodeMap, ConditionalProperty, Exactify, PropertiesOfType, TranscodableProperties, FlattenEntityMap, Transcodes, SortOrder, MutuallyExclusive, NotNever, DefaultTranscodeMap } from '@karmaniverous/entity-tools'; | ||
* @param rangeKeyToken - Index range key. | ||
* @param suppressError - Suppress error if no match found. | ||
* | ||
* @returns Index token if found. | ||
* | ||
* @throws `Error` if no match found and `suppressError` is not `true`. | ||
*/ | ||
findIndexToken(hashKeyToken: string, rangeKeyToken: string): string | undefined; | ||
findIndexToken(hashKeyToken: string, rangeKeyToken: string, suppressError?: boolean): string | undefined; | ||
/** | ||
@@ -601,0 +604,0 @@ * Query a database entity across shards in a provider-generic fashion. |
@@ -112,7 +112,10 @@ import { __classPrivateFieldSet, __classPrivateFieldGet } from 'tslib'; | ||
* @param rangeKeyToken - Index range key. | ||
* @param suppressError - Suppress error if no match found. | ||
* | ||
* @returns Index token if found. | ||
* | ||
* @throws `Error` if no match found and `suppressError` is not `true`. | ||
*/ | ||
findIndexToken(hashKeyToken, rangeKeyToken) { | ||
return findIndexToken(this, hashKeyToken, rangeKeyToken); | ||
findIndexToken(hashKeyToken, rangeKeyToken, suppressError) { | ||
return findIndexToken(this, hashKeyToken, rangeKeyToken, suppressError); | ||
} | ||
@@ -119,0 +122,0 @@ /** |
@@ -7,9 +7,15 @@ /** | ||
* @param rangeKeyToken - Index range key. | ||
* @param suppressError - Suppress error if no match found. | ||
* | ||
* @returns Index token if found. | ||
* | ||
* @throws `Error` if no match found and `suppressError` is not `true`. | ||
*/ | ||
function findIndexToken(entityManager, hashKeyToken, rangeKeyToken) { | ||
return Object.entries(entityManager.config.indexes).find(([, index]) => index.hashKey === hashKeyToken && index.rangeKey === rangeKeyToken)?.[0]; | ||
function findIndexToken(entityManager, hashKeyToken, rangeKeyToken, suppressError) { | ||
const indexToken = Object.entries(entityManager.config.indexes).find(([, index]) => index.hashKey === hashKeyToken && index.rangeKey === rangeKeyToken)?.[0]; | ||
if (!indexToken && !suppressError) | ||
throw new Error(`No index token found for hashKey '${hashKeyToken}' & rangeKey '${rangeKeyToken}'.`); | ||
return indexToken; | ||
} | ||
export { findIndexToken }; |
@@ -135,3 +135,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "6.13.0" | ||
"version": "6.13.1" | ||
} |
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
180064
3905