@karmaniverous/entity-manager 6.13.0 → 6.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -111,11 +111,14 @@ class EntityManager {
|
|
|
111
111
|
*
|
|
112
112
|
* @param hashKeyToken - Index hash key.
|
|
113
113
|
* @param rangeKeyToken - Index range key.
|
|
114
|
+
* @param suppressError - Suppress error if no match found.
|
|
114
115
|
*
|
|
115
116
|
* @returns Index token if found.
|
|
117
|
+
*
|
|
118
|
+
* @throws `Error` if no match found and `suppressError` is not `true`.
|
|
116
119
|
*/
|
|
117
|
-
findIndexToken(hashKeyToken, rangeKeyToken) {
|
|
118
|
-
return findIndexToken.findIndexToken(this, hashKeyToken, rangeKeyToken);
|
|
120
|
+
findIndexToken(hashKeyToken, rangeKeyToken, suppressError) {
|
|
121
|
+
return findIndexToken.findIndexToken(this, hashKeyToken, rangeKeyToken, suppressError);
|
|
119
122
|
}
|
|
120
123
|
/**
|
|
121
124
|
* Query a database entity across shards in a provider-generic fashion.
|
|
@@ -6,11 +6,17 @@
|
|
|
6
6
|
* @param entityManager - {@link EntityManager | `EntityManager`} instance.
|
|
7
7
|
* @param hashKeyToken - Index hash key.
|
|
8
8
|
* @param rangeKeyToken - Index range key.
|
|
9
|
+
* @param suppressError - Suppress error if no match found.
|
|
9
10
|
*
|
|
10
11
|
* @returns Index token if found.
|
|
12
|
+
*
|
|
13
|
+
* @throws `Error` if no match found and `suppressError` is not `true`.
|
|
11
14
|
*/
|
|
12
|
-
function findIndexToken(entityManager, hashKeyToken, rangeKeyToken) {
|
|
13
|
-
|
|
15
|
+
function findIndexToken(entityManager, hashKeyToken, rangeKeyToken, suppressError) {
|
|
16
|
+
const indexToken = Object.entries(entityManager.config.indexes).find(([, index]) => index.hashKey === hashKeyToken && index.rangeKey === rangeKeyToken)?.[0];
|
|
17
|
+
if (!indexToken && !suppressError)
|
|
18
|
+
throw new Error(`No index token found for hashKey '${hashKeyToken}' & rangeKey '${rangeKeyToken}'.`);
|
|
19
|
+
return indexToken;
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
exports.findIndexToken = findIndexToken;
|
package/dist/index.d.ts
CHANGED
|
@@ -592,10 +592,13 @@ declare class EntityManager<C extends BaseConfigMap> {
|
|
|
592
592
|
*
|
|
593
593
|
* @param hashKeyToken - Index hash key.
|
|
594
594
|
* @param rangeKeyToken - Index range key.
|
|
595
|
+
* @param suppressError - Suppress error if no match found.
|
|
595
596
|
*
|
|
596
597
|
* @returns Index token if found.
|
|
598
|
+
*
|
|
599
|
+
* @throws `Error` if no match found and `suppressError` is not `true`.
|
|
597
600
|
*/
|
|
598
|
-
findIndexToken(hashKeyToken: string, rangeKeyToken: string): string | undefined;
|
|
601
|
+
findIndexToken(hashKeyToken: string, rangeKeyToken: string, suppressError?: boolean): string | undefined;
|
|
599
602
|
/**
|
|
600
603
|
* Query a database entity across shards in a provider-generic fashion.
|
|
601
604
|
*
|
|
@@ -109,11 +109,14 @@ class EntityManager {
|
|
|
109
109
|
*
|
|
110
110
|
* @param hashKeyToken - Index hash key.
|
|
111
111
|
* @param rangeKeyToken - Index range key.
|
|
112
|
+
* @param suppressError - Suppress error if no match found.
|
|
112
113
|
*
|
|
113
114
|
* @returns Index token if found.
|
|
115
|
+
*
|
|
116
|
+
* @throws `Error` if no match found and `suppressError` is not `true`.
|
|
114
117
|
*/
|
|
115
|
-
findIndexToken(hashKeyToken, rangeKeyToken) {
|
|
116
|
-
return findIndexToken(this, hashKeyToken, rangeKeyToken);
|
|
118
|
+
findIndexToken(hashKeyToken, rangeKeyToken, suppressError) {
|
|
119
|
+
return findIndexToken(this, hashKeyToken, rangeKeyToken, suppressError);
|
|
117
120
|
}
|
|
118
121
|
/**
|
|
119
122
|
* Query a database entity across shards in a provider-generic fashion.
|
|
@@ -4,11 +4,17 @@
|
|
|
4
4
|
* @param entityManager - {@link EntityManager | `EntityManager`} instance.
|
|
5
5
|
* @param hashKeyToken - Index hash key.
|
|
6
6
|
* @param rangeKeyToken - Index range key.
|
|
7
|
+
* @param suppressError - Suppress error if no match found.
|
|
7
8
|
*
|
|
8
9
|
* @returns Index token if found.
|
|
10
|
+
*
|
|
11
|
+
* @throws `Error` if no match found and `suppressError` is not `true`.
|
|
9
12
|
*/
|
|
10
|
-
function findIndexToken(entityManager, hashKeyToken, rangeKeyToken) {
|
|
11
|
-
|
|
13
|
+
function findIndexToken(entityManager, hashKeyToken, rangeKeyToken, suppressError) {
|
|
14
|
+
const indexToken = Object.entries(entityManager.config.indexes).find(([, index]) => index.hashKey === hashKeyToken && index.rangeKey === rangeKeyToken)?.[0];
|
|
15
|
+
if (!indexToken && !suppressError)
|
|
16
|
+
throw new Error(`No index token found for hashKey '${hashKeyToken}' & rangeKey '${rangeKeyToken}'.`);
|
|
17
|
+
return indexToken;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
export { findIndexToken };
|
package/package.json
CHANGED