dyno-table 2.1.0 → 2.1.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.
- package/README.md +116 -0
- package/dist/builders/query-builder.cjs +44 -21
- package/dist/builders/query-builder.cjs.map +1 -1
- package/dist/builders/query-builder.d.cts +1 -1
- package/dist/builders/query-builder.d.ts +1 -1
- package/dist/builders/query-builder.js +44 -21
- package/dist/builders/query-builder.js.map +1 -1
- package/dist/entity.cjs +18 -19
- package/dist/entity.cjs.map +1 -1
- package/dist/entity.d.cts +2 -2
- package/dist/entity.d.ts +2 -2
- package/dist/entity.js +18 -19
- package/dist/entity.js.map +1 -1
- package/dist/index.cjs +76 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +76 -41
- package/dist/index.js.map +1 -1
- package/dist/{query-builder-BNWRCrJW.d.ts → query-builder-CUWdavZw.d.ts} +2 -0
- package/dist/{query-builder-DZ9JKgBN.d.cts → query-builder-DoZzZz_c.d.cts} +2 -0
- package/dist/{table-BhEeYauU.d.ts → table-4UxlW_wD.d.ts} +2 -1
- package/dist/{table-BpNOboD9.d.cts → table-D-xNCVFa.d.cts} +2 -1
- package/dist/table.cjs +58 -22
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +2 -2
- package/dist/table.d.ts +2 -2
- package/dist/table.js +58 -22
- package/dist/table.js.map +1 -1
- package/package.json +1 -1
|
@@ -143,6 +143,7 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
143
143
|
* @returns The builder instance for method chaining
|
|
144
144
|
*/
|
|
145
145
|
filter(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
146
|
+
private getConditionOperator;
|
|
146
147
|
/**
|
|
147
148
|
* Specifies which attributes to return in the results.
|
|
148
149
|
*
|
|
@@ -431,6 +432,7 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
|
|
|
431
432
|
* @returns A new QueryBuilder instance with the same configuration
|
|
432
433
|
*/
|
|
433
434
|
clone(): QueryBuilder<T, TConfig>;
|
|
435
|
+
private deepCloneFilter;
|
|
434
436
|
/**
|
|
435
437
|
* Executes the query against DynamoDB and returns a generator that behaves like an array.
|
|
436
438
|
*
|
|
@@ -143,6 +143,7 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
143
143
|
* @returns The builder instance for method chaining
|
|
144
144
|
*/
|
|
145
145
|
filter(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
146
|
+
private getConditionOperator;
|
|
146
147
|
/**
|
|
147
148
|
* Specifies which attributes to return in the results.
|
|
148
149
|
*
|
|
@@ -431,6 +432,7 @@ declare class QueryBuilder<T extends DynamoItem, TConfig extends TableConfig = T
|
|
|
431
432
|
* @returns A new QueryBuilder instance with the same configuration
|
|
432
433
|
*/
|
|
433
434
|
clone(): QueryBuilder<T, TConfig>;
|
|
435
|
+
private deepCloneFilter;
|
|
434
436
|
/**
|
|
435
437
|
* Executes the query against DynamoDB and returns a generator that behaves like an array.
|
|
436
438
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamoItem, TableConfig, Index } from './types.js';
|
|
2
2
|
import { r as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-DD0bvyHm.js';
|
|
3
|
-
import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-
|
|
3
|
+
import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-CUWdavZw.js';
|
|
4
4
|
import { PutBuilder } from './builders/put-builder.js';
|
|
5
5
|
import { DeleteBuilder } from './builders/delete-builder.js';
|
|
6
6
|
import { UpdateBuilder } from './builders/update-builder.js';
|
|
@@ -76,6 +76,7 @@ declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = Ta
|
|
|
76
76
|
* @returns A new ScanBuilder instance with the same configuration
|
|
77
77
|
*/
|
|
78
78
|
clone(): ScanBuilder<T, TConfig>;
|
|
79
|
+
private deepCloneFilter;
|
|
79
80
|
/**
|
|
80
81
|
* Executes the scan against DynamoDB and returns a generator that behaves like an array.
|
|
81
82
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamoItem, TableConfig, Index } from './types.cjs';
|
|
2
2
|
import { r as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-CC3NDfUU.cjs';
|
|
3
|
-
import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-
|
|
3
|
+
import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-DoZzZz_c.cjs';
|
|
4
4
|
import { PutBuilder } from './builders/put-builder.cjs';
|
|
5
5
|
import { DeleteBuilder } from './builders/delete-builder.cjs';
|
|
6
6
|
import { UpdateBuilder } from './builders/update-builder.cjs';
|
|
@@ -76,6 +76,7 @@ declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = Ta
|
|
|
76
76
|
* @returns A new ScanBuilder instance with the same configuration
|
|
77
77
|
*/
|
|
78
78
|
clone(): ScanBuilder<T, TConfig>;
|
|
79
|
+
private deepCloneFilter;
|
|
79
80
|
/**
|
|
80
81
|
* Executes the scan against DynamoDB and returns a generator that behaves like an array.
|
|
81
82
|
*
|
package/dist/table.cjs
CHANGED
|
@@ -521,30 +521,40 @@ var FilterBuilder = class {
|
|
|
521
521
|
* @returns The builder instance for method chaining
|
|
522
522
|
*/
|
|
523
523
|
filter(condition) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
beginsWith,
|
|
535
|
-
contains,
|
|
536
|
-
attributeExists,
|
|
537
|
-
attributeNotExists,
|
|
538
|
-
and,
|
|
539
|
-
or,
|
|
540
|
-
not
|
|
541
|
-
};
|
|
542
|
-
this.options.filter = condition(conditionOperator);
|
|
524
|
+
const newCondition = typeof condition === "function" ? condition(this.getConditionOperator()) : condition;
|
|
525
|
+
if (this.options.filter) {
|
|
526
|
+
if (this.options.filter.type === "and" && this.options.filter.conditions) {
|
|
527
|
+
this.options.filter = {
|
|
528
|
+
type: "and",
|
|
529
|
+
conditions: [...this.options.filter.conditions, newCondition]
|
|
530
|
+
};
|
|
531
|
+
} else {
|
|
532
|
+
this.options.filter = and(this.options.filter, newCondition);
|
|
533
|
+
}
|
|
543
534
|
} else {
|
|
544
|
-
this.options.filter =
|
|
535
|
+
this.options.filter = newCondition;
|
|
545
536
|
}
|
|
546
537
|
return this;
|
|
547
538
|
}
|
|
539
|
+
getConditionOperator() {
|
|
540
|
+
return {
|
|
541
|
+
eq,
|
|
542
|
+
ne,
|
|
543
|
+
lt,
|
|
544
|
+
lte,
|
|
545
|
+
gt,
|
|
546
|
+
gte,
|
|
547
|
+
between,
|
|
548
|
+
inArray,
|
|
549
|
+
beginsWith,
|
|
550
|
+
contains,
|
|
551
|
+
attributeExists,
|
|
552
|
+
attributeNotExists,
|
|
553
|
+
and,
|
|
554
|
+
or,
|
|
555
|
+
not
|
|
556
|
+
};
|
|
557
|
+
}
|
|
548
558
|
/**
|
|
549
559
|
* Specifies which attributes to return in the results.
|
|
550
560
|
*
|
|
@@ -835,10 +845,23 @@ var QueryBuilder = class _QueryBuilder extends FilterBuilder {
|
|
|
835
845
|
*/
|
|
836
846
|
clone() {
|
|
837
847
|
const clone = new _QueryBuilder(this.executor, this.keyCondition);
|
|
838
|
-
clone.options = {
|
|
848
|
+
clone.options = {
|
|
849
|
+
...this.options,
|
|
850
|
+
filter: this.deepCloneFilter(this.options.filter)
|
|
851
|
+
};
|
|
839
852
|
clone.selectedFields = new Set(this.selectedFields);
|
|
840
853
|
return clone;
|
|
841
854
|
}
|
|
855
|
+
deepCloneFilter(filter) {
|
|
856
|
+
if (!filter) return filter;
|
|
857
|
+
if (filter.type === "and" || filter.type === "or") {
|
|
858
|
+
return {
|
|
859
|
+
...filter,
|
|
860
|
+
conditions: filter.conditions?.map((condition) => this.deepCloneFilter(condition)).filter((c) => c !== void 0)
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
return { ...filter };
|
|
864
|
+
}
|
|
842
865
|
/**
|
|
843
866
|
* Executes the query against DynamoDB and returns a generator that behaves like an array.
|
|
844
867
|
*
|
|
@@ -3157,10 +3180,23 @@ var ScanBuilder = class _ScanBuilder extends FilterBuilder {
|
|
|
3157
3180
|
*/
|
|
3158
3181
|
clone() {
|
|
3159
3182
|
const clone = new _ScanBuilder(this.executor);
|
|
3160
|
-
clone.options = {
|
|
3183
|
+
clone.options = {
|
|
3184
|
+
...this.options,
|
|
3185
|
+
filter: this.deepCloneFilter(this.options.filter)
|
|
3186
|
+
};
|
|
3161
3187
|
clone.selectedFields = new Set(this.selectedFields);
|
|
3162
3188
|
return clone;
|
|
3163
3189
|
}
|
|
3190
|
+
deepCloneFilter(filter) {
|
|
3191
|
+
if (!filter) return filter;
|
|
3192
|
+
if (filter.type === "and" || filter.type === "or") {
|
|
3193
|
+
return {
|
|
3194
|
+
...filter,
|
|
3195
|
+
conditions: filter.conditions?.map((condition) => this.deepCloneFilter(condition)).filter((c) => c !== void 0)
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
return { ...filter };
|
|
3199
|
+
}
|
|
3164
3200
|
/**
|
|
3165
3201
|
* Executes the scan against DynamoDB and returns a generator that behaves like an array.
|
|
3166
3202
|
*
|