electrodb 3.7.0 → 3.7.2
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.
- package/index.d.ts +12 -1
- package/package.json +1 -1
- package/src/clauses.js +2 -2
- package/src/entity.js +10 -3
package/index.d.ts
CHANGED
|
@@ -2632,6 +2632,7 @@ export interface QueryOptions {
|
|
|
2632
2632
|
data?: "raw" | "includeKeys" | "attributes";
|
|
2633
2633
|
order?: "asc" | "desc";
|
|
2634
2634
|
consistent?: boolean;
|
|
2635
|
+
client?: DocumentClient;
|
|
2635
2636
|
}
|
|
2636
2637
|
|
|
2637
2638
|
// subset of QueryOptions
|
|
@@ -2721,6 +2722,7 @@ interface GoBatchGetTerminalOptions<Attributes> {
|
|
|
2721
2722
|
listeners?: Array<ElectroEventListener>;
|
|
2722
2723
|
logger?: ElectroEventListener;
|
|
2723
2724
|
consistent?: boolean;
|
|
2725
|
+
client?: DocumentClient;
|
|
2724
2726
|
}
|
|
2725
2727
|
|
|
2726
2728
|
export type ExecutionOptionCompare = "keys" | "attributes" | "v2";
|
|
@@ -2752,6 +2754,7 @@ type ServiceQueryGoTerminalOptions<
|
|
|
2752
2754
|
logger?: ElectroEventListener;
|
|
2753
2755
|
order?: "asc" | "desc";
|
|
2754
2756
|
consistent?: boolean;
|
|
2757
|
+
client?: DocumentClient;
|
|
2755
2758
|
} & QueryExecutionComparisonParts &
|
|
2756
2759
|
(
|
|
2757
2760
|
| {
|
|
@@ -2820,6 +2823,7 @@ type GoQueryTerminalOptions<
|
|
|
2820
2823
|
order?: "asc" | "desc";
|
|
2821
2824
|
hydrate?: boolean;
|
|
2822
2825
|
consistent?: boolean;
|
|
2826
|
+
client?: DocumentClient;
|
|
2823
2827
|
} & QueryExecutionComparisonParts &
|
|
2824
2828
|
(
|
|
2825
2829
|
| {
|
|
@@ -2847,6 +2851,7 @@ interface TransactWriteQueryOptions {
|
|
|
2847
2851
|
listeners?: Array<ElectroEventListener>;
|
|
2848
2852
|
logger?: ElectroEventListener;
|
|
2849
2853
|
response?: "all_old";
|
|
2854
|
+
client?: DocumentClient;
|
|
2850
2855
|
}
|
|
2851
2856
|
|
|
2852
2857
|
interface TransactGetQueryOptions<Attributes> {
|
|
@@ -2859,6 +2864,7 @@ interface TransactGetQueryOptions<Attributes> {
|
|
|
2859
2864
|
listeners?: Array<ElectroEventListener>;
|
|
2860
2865
|
logger?: ElectroEventListener;
|
|
2861
2866
|
consistent?: boolean;
|
|
2867
|
+
client?: DocumentClient;
|
|
2862
2868
|
}
|
|
2863
2869
|
|
|
2864
2870
|
export type ParamTerminalOptions<Attributes> = {
|
|
@@ -5899,9 +5905,14 @@ export class TransactGetEntity<
|
|
|
5899
5905
|
type TransactWriteFunctionOptions = {
|
|
5900
5906
|
token?: string;
|
|
5901
5907
|
logger?: ElectroEventListener;
|
|
5908
|
+
client?: DocumentClient;
|
|
5902
5909
|
};
|
|
5903
5910
|
|
|
5904
|
-
type TransactGetFunctionOptions = {
|
|
5911
|
+
type TransactGetFunctionOptions = {
|
|
5912
|
+
token?: string;
|
|
5913
|
+
logger?: ElectroEventListener;
|
|
5914
|
+
client?: DocumentClient;
|
|
5915
|
+
};
|
|
5905
5916
|
|
|
5906
5917
|
type TransactWriteExtractedType<
|
|
5907
5918
|
T extends readonly any[],
|
package/package.json
CHANGED
package/src/clauses.js
CHANGED
|
@@ -1358,10 +1358,10 @@ let clauses = {
|
|
|
1358
1358
|
return Promise.reject(state.error);
|
|
1359
1359
|
}
|
|
1360
1360
|
try {
|
|
1361
|
-
if (entity.client === undefined) {
|
|
1361
|
+
if (entity.client === undefined && options.client === undefined) {
|
|
1362
1362
|
throw new e.ElectroError(
|
|
1363
1363
|
e.ErrorCodes.NoClientDefined,
|
|
1364
|
-
"No client defined on model",
|
|
1364
|
+
"No client defined on model or provided in query options",
|
|
1365
1365
|
);
|
|
1366
1366
|
}
|
|
1367
1367
|
options.terminalOperation = TerminalOperation.go;
|
package/src/entity.js
CHANGED
|
@@ -516,7 +516,8 @@ class Entity {
|
|
|
516
516
|
);
|
|
517
517
|
};
|
|
518
518
|
const dynamoDBMethod = MethodTypeTranslation[method];
|
|
519
|
-
|
|
519
|
+
const client = config.client || this.client;
|
|
520
|
+
return client[dynamoDBMethod](params)
|
|
520
521
|
.promise()
|
|
521
522
|
.then((results) => {
|
|
522
523
|
notifyQuery();
|
|
@@ -920,6 +921,8 @@ class Entity {
|
|
|
920
921
|
is(item, config) {
|
|
921
922
|
return (
|
|
922
923
|
config.ignoreOwnership &&
|
|
924
|
+
config.attributes &&
|
|
925
|
+
config.attributes.length > 0 &&
|
|
923
926
|
!this._itemIncludesKeys(item)
|
|
924
927
|
) || (
|
|
925
928
|
(config.ignoreOwnership || config.hydrate) &&
|
|
@@ -1018,8 +1021,8 @@ class Entity {
|
|
|
1018
1021
|
return null;
|
|
1019
1022
|
}
|
|
1020
1023
|
const config = {
|
|
1021
|
-
...(options || {}),
|
|
1022
1024
|
ignoreOwnership: true,
|
|
1025
|
+
...(options || {}),
|
|
1023
1026
|
};
|
|
1024
1027
|
return this.formatResponse(item, TableIndex, config);
|
|
1025
1028
|
}
|
|
@@ -1931,6 +1934,10 @@ class Entity {
|
|
|
1931
1934
|
config.hydrator = option.hydrator;
|
|
1932
1935
|
}
|
|
1933
1936
|
|
|
1937
|
+
if (option.client !== undefined) {
|
|
1938
|
+
config.client = c.normalizeClient(option.client);
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1934
1941
|
if (option._includeOnResponseItem) {
|
|
1935
1942
|
config._includeOnResponseItem = {
|
|
1936
1943
|
...config._includeOnResponseItem,
|
|
@@ -2762,7 +2769,7 @@ class Entity {
|
|
|
2762
2769
|
let is = {}
|
|
2763
2770
|
let start = {}
|
|
2764
2771
|
let end = {};
|
|
2765
|
-
(state.query.keys.sk
|
|
2772
|
+
(state.query.keys.sk || []).forEach(({type, facets}) => {
|
|
2766
2773
|
if (type === QueryTypes.is || type === QueryTypes.composite_collection) {
|
|
2767
2774
|
is = facets;
|
|
2768
2775
|
} else if (type === QueryTypes.between) {
|