electrodb 2.2.4 → 2.2.6
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/package.json +1 -1
- package/src/entity.js +5 -1
- package/src/operations.js +33 -18
package/package.json
CHANGED
package/src/entity.js
CHANGED
|
@@ -54,7 +54,7 @@ class Entity {
|
|
|
54
54
|
this._whereBuilder = new WhereFactory(this.model.schema.attributes, FilterOperations);
|
|
55
55
|
this._clausesWithFilters = this._filterBuilder.injectFilterClauses(clauses, this.model.filters);
|
|
56
56
|
this._clausesWithFilters = this._whereBuilder.injectWhereClauses(this._clausesWithFilters);
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
this.query = {};
|
|
59
59
|
for (let accessPattern in this.model.indexes) {
|
|
60
60
|
let index = this.model.indexes[accessPattern].index;
|
|
@@ -75,6 +75,10 @@ class Entity {
|
|
|
75
75
|
this.schema = model;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
get scan() {
|
|
79
|
+
return this._makeChain(TableIndex, this._clausesWithFilters, clauses.index, {_isPagination: true}).scan();
|
|
80
|
+
}
|
|
81
|
+
|
|
78
82
|
setIdentifier(type = "", identifier = "") {
|
|
79
83
|
if (!this.identifiers[type]) {
|
|
80
84
|
throw new e.ElectroError(e.ErrorCodes.InvalidIdentifier, `Invalid identifier type: "${type}". Valid identifiers include: ${u.commaSeparatedString(Object.keys(this.identifiers))}`);
|
package/src/operations.js
CHANGED
|
@@ -431,24 +431,32 @@ class AttributeOperationProxy {
|
|
|
431
431
|
return ops;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
static pathProxy(
|
|
435
|
-
return new Proxy(() => (
|
|
436
|
-
get: (_, prop) => {
|
|
434
|
+
static pathProxy(build) {
|
|
435
|
+
return new Proxy(() => build(), {
|
|
436
|
+
get: (_, prop, o) => {
|
|
437
437
|
if (prop === "__is_clause__") {
|
|
438
|
-
return AttributeProxySymbol
|
|
438
|
+
return AttributeProxySymbol;
|
|
439
439
|
} else {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
440
|
+
return AttributeOperationProxy.pathProxy(() => {
|
|
441
|
+
const { paths, root, target, builder } = build();
|
|
442
|
+
const attribute = target.getChild(prop);
|
|
443
|
+
let field;
|
|
444
|
+
if (attribute === undefined) {
|
|
445
|
+
throw new Error(`Invalid attribute "${prop}" at path "${paths.json}".`);
|
|
446
|
+
} else if (attribute === root && attribute.type === AttributeTypes.any) {
|
|
447
|
+
// This function is only called if a nested property is called. If this attribute is ultimately the root, don't use the root's field name
|
|
448
|
+
field = prop;
|
|
449
|
+
} else {
|
|
450
|
+
field = attribute.field;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return {
|
|
454
|
+
root,
|
|
455
|
+
builder,
|
|
456
|
+
target: attribute,
|
|
457
|
+
paths: builder.setName(paths, prop, field),
|
|
458
|
+
}
|
|
459
|
+
});
|
|
452
460
|
}
|
|
453
461
|
}
|
|
454
462
|
});
|
|
@@ -459,8 +467,15 @@ class AttributeOperationProxy {
|
|
|
459
467
|
for (let [name, attribute] of Object.entries(attributes)) {
|
|
460
468
|
Object.defineProperty(attr, name, {
|
|
461
469
|
get: () => {
|
|
462
|
-
|
|
463
|
-
|
|
470
|
+
return AttributeOperationProxy.pathProxy(() => {
|
|
471
|
+
const paths = builder.setName({}, attribute.name, attribute.field);
|
|
472
|
+
return {
|
|
473
|
+
paths,
|
|
474
|
+
root: attribute,
|
|
475
|
+
target: attribute,
|
|
476
|
+
builder,
|
|
477
|
+
}
|
|
478
|
+
});
|
|
464
479
|
}
|
|
465
480
|
});
|
|
466
481
|
}
|