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/dist/table.d.cts CHANGED
@@ -1,13 +1,13 @@
1
1
  import './types.cjs';
2
2
  import './conditions-CC3NDfUU.cjs';
3
- import './query-builder-DZ9JKgBN.cjs';
3
+ import './query-builder-DoZzZz_c.cjs';
4
4
  import './builders/put-builder.cjs';
5
5
  import './builders/delete-builder.cjs';
6
6
  import './builders/update-builder.cjs';
7
7
  import './builders/transaction-builder.cjs';
8
8
  import './batch-builder-CcxFDKhe.cjs';
9
9
  import './builders/condition-check-builder.cjs';
10
- export { T as Table } from './table-BpNOboD9.cjs';
10
+ export { T as Table } from './table-D-xNCVFa.cjs';
11
11
  import '@aws-sdk/lib-dynamodb';
12
12
  import './builders/paginator.cjs';
13
13
  import './builder-types-BTVhQSHI.cjs';
package/dist/table.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import './types.js';
2
2
  import './conditions-DD0bvyHm.js';
3
- import './query-builder-BNWRCrJW.js';
3
+ import './query-builder-CUWdavZw.js';
4
4
  import './builders/put-builder.js';
5
5
  import './builders/delete-builder.js';
6
6
  import './builders/update-builder.js';
7
7
  import './builders/transaction-builder.js';
8
8
  import './batch-builder-BytHNL_u.js';
9
9
  import './builders/condition-check-builder.js';
10
- export { T as Table } from './table-BhEeYauU.js';
10
+ export { T as Table } from './table-4UxlW_wD.js';
11
11
  import '@aws-sdk/lib-dynamodb';
12
12
  import './builders/paginator.js';
13
13
  import './builder-types-CzuLR4Th.js';
package/dist/table.js CHANGED
@@ -519,30 +519,40 @@ var FilterBuilder = class {
519
519
  * @returns The builder instance for method chaining
520
520
  */
521
521
  filter(condition) {
522
- if (typeof condition === "function") {
523
- const conditionOperator = {
524
- eq,
525
- ne,
526
- lt,
527
- lte,
528
- gt,
529
- gte,
530
- between,
531
- inArray,
532
- beginsWith,
533
- contains,
534
- attributeExists,
535
- attributeNotExists,
536
- and,
537
- or,
538
- not
539
- };
540
- this.options.filter = condition(conditionOperator);
522
+ const newCondition = typeof condition === "function" ? condition(this.getConditionOperator()) : condition;
523
+ if (this.options.filter) {
524
+ if (this.options.filter.type === "and" && this.options.filter.conditions) {
525
+ this.options.filter = {
526
+ type: "and",
527
+ conditions: [...this.options.filter.conditions, newCondition]
528
+ };
529
+ } else {
530
+ this.options.filter = and(this.options.filter, newCondition);
531
+ }
541
532
  } else {
542
- this.options.filter = condition;
533
+ this.options.filter = newCondition;
543
534
  }
544
535
  return this;
545
536
  }
537
+ getConditionOperator() {
538
+ return {
539
+ eq,
540
+ ne,
541
+ lt,
542
+ lte,
543
+ gt,
544
+ gte,
545
+ between,
546
+ inArray,
547
+ beginsWith,
548
+ contains,
549
+ attributeExists,
550
+ attributeNotExists,
551
+ and,
552
+ or,
553
+ not
554
+ };
555
+ }
546
556
  /**
547
557
  * Specifies which attributes to return in the results.
548
558
  *
@@ -833,10 +843,23 @@ var QueryBuilder = class _QueryBuilder extends FilterBuilder {
833
843
  */
834
844
  clone() {
835
845
  const clone = new _QueryBuilder(this.executor, this.keyCondition);
836
- clone.options = { ...this.options };
846
+ clone.options = {
847
+ ...this.options,
848
+ filter: this.deepCloneFilter(this.options.filter)
849
+ };
837
850
  clone.selectedFields = new Set(this.selectedFields);
838
851
  return clone;
839
852
  }
853
+ deepCloneFilter(filter) {
854
+ if (!filter) return filter;
855
+ if (filter.type === "and" || filter.type === "or") {
856
+ return {
857
+ ...filter,
858
+ conditions: filter.conditions?.map((condition) => this.deepCloneFilter(condition)).filter((c) => c !== void 0)
859
+ };
860
+ }
861
+ return { ...filter };
862
+ }
840
863
  /**
841
864
  * Executes the query against DynamoDB and returns a generator that behaves like an array.
842
865
  *
@@ -3155,10 +3178,23 @@ var ScanBuilder = class _ScanBuilder extends FilterBuilder {
3155
3178
  */
3156
3179
  clone() {
3157
3180
  const clone = new _ScanBuilder(this.executor);
3158
- clone.options = { ...this.options };
3181
+ clone.options = {
3182
+ ...this.options,
3183
+ filter: this.deepCloneFilter(this.options.filter)
3184
+ };
3159
3185
  clone.selectedFields = new Set(this.selectedFields);
3160
3186
  return clone;
3161
3187
  }
3188
+ deepCloneFilter(filter) {
3189
+ if (!filter) return filter;
3190
+ if (filter.type === "and" || filter.type === "or") {
3191
+ return {
3192
+ ...filter,
3193
+ conditions: filter.conditions?.map((condition) => this.deepCloneFilter(condition)).filter((c) => c !== void 0)
3194
+ };
3195
+ }
3196
+ return { ...filter };
3197
+ }
3162
3198
  /**
3163
3199
  * Executes the scan against DynamoDB and returns a generator that behaves like an array.
3164
3200
  *