dyna-record 0.1.5 → 0.2.0
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 +11 -13
- package/dist/src/DynaRecord.d.ts +36 -28
- package/dist/src/DynaRecord.d.ts.map +1 -1
- package/dist/src/DynaRecord.js +39 -36
- package/dist/src/decorators/Table.d.ts.map +1 -1
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/EnumAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/NumberAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/StringAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/serializers.d.ts +1 -1
- package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -1
- package/dist/src/decorators/types.d.ts +2 -2
- package/dist/src/decorators/types.d.ts.map +1 -1
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts +4 -0
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts.map +1 -1
- package/dist/src/dynamo-utils/TransactGetBuilder.js +6 -0
- package/dist/src/metadata/EntityMetadata.d.ts +13 -1
- package/dist/src/metadata/EntityMetadata.d.ts.map +1 -1
- package/dist/src/metadata/EntityMetadata.js +21 -0
- package/dist/src/metadata/TableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/TableMetadata.js +1 -3
- package/dist/src/metadata/relationship-metadata/types.d.ts +4 -0
- package/dist/src/metadata/relationship-metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/types.d.ts +2 -3
- package/dist/src/metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/utils.d.ts.map +1 -1
- package/dist/src/operations/Create/Create.d.ts +95 -16
- package/dist/src/operations/Create/Create.d.ts.map +1 -1
- package/dist/src/operations/Create/Create.js +170 -22
- package/dist/src/operations/Delete/Delete.d.ts +29 -25
- package/dist/src/operations/Delete/Delete.d.ts.map +1 -1
- package/dist/src/operations/Delete/Delete.js +105 -104
- package/dist/src/operations/Delete/types.d.ts +0 -3
- package/dist/src/operations/Delete/types.d.ts.map +1 -1
- package/dist/src/operations/FindById/FindById.d.ts +7 -28
- package/dist/src/operations/FindById/FindById.d.ts.map +1 -1
- package/dist/src/operations/FindById/FindById.js +36 -125
- package/dist/src/operations/FindById/types.d.ts +8 -9
- package/dist/src/operations/FindById/types.d.ts.map +1 -1
- package/dist/src/operations/Query/Query.d.ts +2 -1
- package/dist/src/operations/Query/Query.d.ts.map +1 -1
- package/dist/src/operations/Query/Query.js +17 -4
- package/dist/src/operations/Query/types.d.ts +39 -5
- package/dist/src/operations/Query/types.d.ts.map +1 -1
- package/dist/src/operations/Update/Update.d.ts +185 -24
- package/dist/src/operations/Update/Update.d.ts.map +1 -1
- package/dist/src/operations/Update/Update.js +402 -72
- package/dist/src/operations/Update/UpdateDryRun.d.ts +10 -0
- package/dist/src/operations/Update/UpdateDryRun.d.ts.map +1 -0
- package/dist/src/operations/Update/UpdateDryRun.js +15 -0
- package/dist/src/operations/Update/index.d.ts +1 -0
- package/dist/src/operations/Update/index.d.ts.map +1 -1
- package/dist/src/operations/Update/index.js +3 -1
- package/dist/src/operations/types.d.ts +6 -1
- package/dist/src/operations/types.d.ts.map +1 -1
- package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -1
- package/dist/src/operations/utils/expressionBuilder.js +1 -4
- package/dist/src/operations/utils/index.d.ts +0 -1
- package/dist/src/operations/utils/index.d.ts.map +1 -1
- package/dist/src/operations/utils/index.js +0 -6
- package/dist/src/operations/utils/utils.d.ts +13 -3
- package/dist/src/operations/utils/utils.d.ts.map +1 -1
- package/dist/src/operations/utils/utils.js +33 -3
- package/dist/src/query-utils/Filters.d.ts +1 -1
- package/dist/src/query-utils/Filters.d.ts.map +1 -1
- package/dist/src/query-utils/Filters.js +7 -15
- package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.js +9 -1
- package/dist/src/relationships/JoinTable.d.ts +17 -7
- package/dist/src/relationships/JoinTable.d.ts.map +1 -1
- package/dist/src/relationships/JoinTable.js +77 -20
- package/dist/src/relationships/index.d.ts +0 -1
- package/dist/src/relationships/index.d.ts.map +1 -1
- package/dist/src/relationships/index.js +1 -3
- package/dist/src/types.d.ts +6 -8
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils.d.ts +10 -32
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +13 -59
- package/package.json +4 -4
- package/dist/src/operations/utils/RelationshipTransactions.d.ts +0 -64
- package/dist/src/operations/utils/RelationshipTransactions.d.ts.map +0 -1
- package/dist/src/operations/utils/RelationshipTransactions.js +0 -125
- package/dist/src/relationships/BelongsToLink.d.ts +0 -51
- package/dist/src/relationships/BelongsToLink.d.ts.map +0 -1
- package/dist/src/relationships/BelongsToLink.js +0 -57
|
@@ -3,19 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const DynaRecord_1 = __importDefault(require("../../DynaRecord"));
|
|
7
6
|
const dynamo_utils_1 = require("../../dynamo-utils");
|
|
8
7
|
const errors_1 = require("../../errors");
|
|
9
8
|
const metadata_1 = __importDefault(require("../../metadata"));
|
|
10
9
|
const utils_1 = require("../../metadata/utils");
|
|
11
|
-
const relationships_1 = require("../../relationships");
|
|
12
10
|
const utils_2 = require("../../utils");
|
|
13
11
|
const OperationBase_1 = __importDefault(require("../OperationBase"));
|
|
12
|
+
const Update_1 = require("../Update");
|
|
14
13
|
const utils_3 = require("../utils");
|
|
15
14
|
/**
|
|
16
15
|
* Implements the operation for deleting an entity and its related data from the database within the ORM framework.
|
|
17
16
|
*
|
|
18
|
-
* Delete an entity, everything in its partition,
|
|
17
|
+
* Delete an entity, everything in its partition, denormalized records and nullifies ForeignKeys on attributes that BelongTo it
|
|
19
18
|
* If the foreign key is non nullable than it will throw a NullConstraintViolationError
|
|
20
19
|
*
|
|
21
20
|
* The `Delete` operation supports complex scenarios, such as deleting related entities in "BelongsTo" relationships, nullifying or removing foreign keys to maintain data integrity, and handling many-to-many relationships through join tables.
|
|
@@ -45,33 +44,22 @@ class Delete extends OperationBase_1.default {
|
|
|
45
44
|
* Delete an item by id
|
|
46
45
|
* - Deletes the given entity
|
|
47
46
|
* - Deletes each item in the entity's partition
|
|
48
|
-
* - For each item in the entity's partition which is
|
|
47
|
+
* - For each item in the entity's partition which is a denormalized record it:
|
|
49
48
|
* - Will nullify the associated relationship's ForeignKey attribute if the attribute is nullable
|
|
50
49
|
* @param id
|
|
51
50
|
*/
|
|
52
51
|
async run(id) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (item instanceof relationships_1.BelongsToLink) {
|
|
65
|
-
this.buildDeleteItemTransaction(item, {
|
|
66
|
-
errorMessage: `Failed to delete BelongsToLink with keys: ${JSON.stringify({
|
|
67
|
-
[this.#partitionKeyField]: item[this.#partitionKeyField],
|
|
68
|
-
[this.#sortKeyField]: item[this.#sortKeyField]
|
|
69
|
-
})}`
|
|
70
|
-
});
|
|
71
|
-
this.buildNullifyForeignKeyTransaction(item);
|
|
72
|
-
this.buildDeleteJoinTableLinkTransaction(item);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
52
|
+
const preFetchRes = await this.preFetch(id);
|
|
53
|
+
this.buildDeleteSelfTransactions(preFetchRes.self);
|
|
54
|
+
preFetchRes.linkedEntities.forEach(item => {
|
|
55
|
+
this.buildDeleteEntityTransaction(item, {
|
|
56
|
+
errorMessage: `Failed to delete denormalized record with keys: ${JSON.stringify(this.buildKeyObject(item, this.#partitionKeyField, this.#sortKeyField))}`
|
|
57
|
+
});
|
|
58
|
+
this.buildDeleteJoinTableLinkTransaction(item);
|
|
59
|
+
});
|
|
60
|
+
await Promise.all(preFetchRes.linkedEntitiesWithFkRef.map(async (entity) => {
|
|
61
|
+
await this.buildNullifyForeignKeyTransaction(entity);
|
|
62
|
+
}));
|
|
75
63
|
if (this.#validationErrors.length === 0) {
|
|
76
64
|
await this.#transactionBuilder.executeTransaction();
|
|
77
65
|
}
|
|
@@ -80,35 +68,75 @@ class Delete extends OperationBase_1.default {
|
|
|
80
68
|
}
|
|
81
69
|
}
|
|
82
70
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
71
|
+
* Prefetch the item being deleted including items in its partition from denormalized associated records
|
|
72
|
+
* @param id
|
|
73
|
+
* @returns - The item and its associated links denormalized
|
|
74
|
+
*/
|
|
75
|
+
async preFetch(id) {
|
|
76
|
+
const items = await this.EntityClass.query(id);
|
|
77
|
+
const prefetchResult = items.reduce((acc, item) => {
|
|
78
|
+
const isItemSelf = item.id === id && item instanceof this.EntityClass;
|
|
79
|
+
if (isItemSelf) {
|
|
80
|
+
acc.self = item;
|
|
81
|
+
}
|
|
82
|
+
else if (this.doesEntityNeedForeignKeyNullified(item)) {
|
|
83
|
+
acc.linkedEntitiesWithFkRef.push(item);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
acc.linkedEntities.push(item);
|
|
87
|
+
}
|
|
88
|
+
return acc;
|
|
89
|
+
}, { linkedEntities: [], linkedEntitiesWithFkRef: [] });
|
|
90
|
+
if (prefetchResult.self === undefined) {
|
|
91
|
+
throw new errors_1.NotFoundError(`Item does not exist: ${id}`);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
self: prefetchResult.self,
|
|
95
|
+
linkedEntities: prefetchResult.linkedEntities,
|
|
96
|
+
linkedEntitiesWithFkRef: prefetchResult.linkedEntitiesWithFkRef
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns true if the linked entity needs to have a foreign key nullified
|
|
101
|
+
* @param relMeta
|
|
102
|
+
* @returns
|
|
85
103
|
*/
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
104
|
+
doesEntityNeedForeignKeyNullified(linkedEntity) {
|
|
105
|
+
const relMeta = this.#relationsLookup[linkedEntity.type];
|
|
106
|
+
return (!(0, utils_1.isBelongsToRelationship)(relMeta) &&
|
|
107
|
+
(0, utils_1.isRelationshipMetadataWithForeignKey)(relMeta));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Delete the entity and denormalized links from BelongsTo relationships
|
|
111
|
+
* @param self
|
|
112
|
+
*/
|
|
113
|
+
buildDeleteSelfTransactions(self) {
|
|
114
|
+
this.buildDeleteEntityTransaction(self, {
|
|
115
|
+
errorMessage: `Failed to delete ${this.EntityClass.name} with Id: ${self.id}`
|
|
116
|
+
});
|
|
117
|
+
this.buildDeleteAssociatedBelongsTransaction(self.id, self);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Deletes an item when given the table keys
|
|
121
|
+
* @param keys - The key to delete representing the table keys, as opposed to the entities keys
|
|
122
|
+
*/
|
|
123
|
+
buildDeleteItemTransaction(keys, options) {
|
|
89
124
|
this.#transactionBuilder.addDelete({
|
|
90
125
|
TableName: this.#tableName,
|
|
91
|
-
Key:
|
|
92
|
-
[this.partitionKeyAlias]: item[pkField],
|
|
93
|
-
[this.sortKeyAlias]: item[skField]
|
|
94
|
-
}
|
|
126
|
+
Key: keys
|
|
95
127
|
}, options.errorMessage);
|
|
96
128
|
}
|
|
97
129
|
/**
|
|
98
|
-
*
|
|
99
|
-
* @param
|
|
130
|
+
* Deletes an item when given the keys of the entity. Converts the keys to the table alias
|
|
131
|
+
* @param keys - The key to delete representing the entity keys, as opposed to the table keys
|
|
100
132
|
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
[this
|
|
107
|
-
|
|
108
|
-
};
|
|
109
|
-
this.buildDeleteItemTransaction(belongsToLinksKeys, {
|
|
110
|
-
errorMessage: `Failed to delete BelongsToLink with keys: ${JSON.stringify(belongsToLinksKeys)}`
|
|
111
|
-
});
|
|
133
|
+
buildDeleteEntityTransaction(keys, options) {
|
|
134
|
+
if ((0, utils_2.isKeyOfObject)(keys, this.#partitionKeyField) &&
|
|
135
|
+
(0, utils_2.isKeyOfObject)(keys, this.#sortKeyField)) {
|
|
136
|
+
this.buildDeleteItemTransaction({
|
|
137
|
+
[this.partitionKeyAlias]: keys[this.#partitionKeyField],
|
|
138
|
+
[this.sortKeyAlias]: keys[this.#sortKeyField]
|
|
139
|
+
}, options);
|
|
112
140
|
}
|
|
113
141
|
}
|
|
114
142
|
/**
|
|
@@ -116,28 +144,18 @@ class Delete extends OperationBase_1.default {
|
|
|
116
144
|
* If the ForeignKey is non nullable than it throws a NullConstraintViolationError
|
|
117
145
|
* @param item
|
|
118
146
|
*/
|
|
119
|
-
buildNullifyForeignKeyTransaction(item) {
|
|
120
|
-
const relMeta = this.#relationsLookup[item.
|
|
147
|
+
async buildNullifyForeignKeyTransaction(item) {
|
|
148
|
+
const relMeta = this.#relationsLookup[item.type];
|
|
121
149
|
if ((0, utils_1.isRelationshipMetadataWithForeignKey)(relMeta)) {
|
|
122
150
|
const entityAttrs = metadata_1.default.getEntityAttributes(relMeta.target.name);
|
|
123
151
|
const attrMeta = Object.values(entityAttrs).find(attr => attr.name === relMeta.foreignKey);
|
|
124
152
|
if (attrMeta?.nullable === false) {
|
|
125
153
|
this.trackValidationError(new errors_1.NullConstraintViolationError(`Cannot set ${relMeta.target.name} with id: '${item.id}' attribute '${relMeta.foreignKey}' to null`));
|
|
126
154
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
[
|
|
130
|
-
}
|
|
131
|
-
const tableAttrs = (0, utils_2.entityToTableItem)(relMeta.target, {
|
|
132
|
-
[relMeta.foreignKey]: null
|
|
133
|
-
});
|
|
134
|
-
const expression = (0, utils_3.expressionBuilder)(tableAttrs);
|
|
135
|
-
this.#transactionBuilder.addUpdate({
|
|
136
|
-
TableName: this.#tableName,
|
|
137
|
-
Key: tableKeys,
|
|
138
|
-
UpdateExpression: expression.UpdateExpression,
|
|
139
|
-
ExpressionAttributeNames: expression.ExpressionAttributeNames
|
|
140
|
-
}, `Failed to remove foreign key attribute from ${relMeta.target.name} with Id: ${item.foreignKey}`);
|
|
155
|
+
else {
|
|
156
|
+
const op = new Update_1.UpdateDryRun(relMeta.target, this.#transactionBuilder);
|
|
157
|
+
await op.run(item.id, { [relMeta.foreignKey]: null });
|
|
158
|
+
}
|
|
141
159
|
}
|
|
142
160
|
}
|
|
143
161
|
/**
|
|
@@ -150,51 +168,25 @@ class Delete extends OperationBase_1.default {
|
|
|
150
168
|
if ((0, utils_2.isKeyOfObject)(item, relMeta.foreignKey) &&
|
|
151
169
|
item[relMeta.foreignKey] !== undefined) {
|
|
152
170
|
const foreignKeyValue = item[relMeta.foreignKey];
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
this.buildDeleteBelongsToHasOneTransaction(relMeta, foreignKeyValue);
|
|
158
|
-
}
|
|
171
|
+
const belongsToLinksKeys = (0, utils_3.buildBelongsToLinkKey)(this.EntityClass, entityId, relMeta, foreignKeyValue);
|
|
172
|
+
this.buildDeleteItemTransaction(belongsToLinksKeys, {
|
|
173
|
+
errorMessage: `Failed to delete denormalized record with keys: ${JSON.stringify(belongsToLinksKeys)}`
|
|
174
|
+
});
|
|
159
175
|
}
|
|
160
176
|
});
|
|
161
177
|
}
|
|
162
178
|
/**
|
|
163
|
-
*
|
|
164
|
-
* @param
|
|
165
|
-
* @param entityId
|
|
166
|
-
* @param foreignKeyValue
|
|
167
|
-
*/
|
|
168
|
-
buildDeleteBelongsToHasManyTransaction(relMeta, entityId, foreignKeyValue) {
|
|
169
|
-
const belongsToLinksKeys = {
|
|
170
|
-
[this.#partitionKeyField]: relMeta.target.partitionKeyValue(foreignKeyValue),
|
|
171
|
-
[this.#sortKeyField]: this.EntityClass.partitionKeyValue(entityId)
|
|
172
|
-
};
|
|
173
|
-
this.buildDeleteItemTransaction(belongsToLinksKeys, {
|
|
174
|
-
errorMessage: `Failed to delete BelongsToLink with keys: ${JSON.stringify(belongsToLinksKeys)}`
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Deletes associated BelongsToLink for a BelongsTo HasOne relationship
|
|
179
|
-
* @param relMeta
|
|
180
|
-
* @param foreignKeyValue
|
|
181
|
-
*/
|
|
182
|
-
buildDeleteBelongsToHasOneTransaction(relMeta, foreignKeyValue) {
|
|
183
|
-
const belongsToLinksKeys = {
|
|
184
|
-
[this.#partitionKeyField]: relMeta.target.partitionKeyValue(foreignKeyValue),
|
|
185
|
-
[this.#sortKeyField]: this.EntityClass.name
|
|
186
|
-
};
|
|
187
|
-
this.buildDeleteItemTransaction(belongsToLinksKeys, {
|
|
188
|
-
errorMessage: `Failed to delete BelongsToLink with keys: ${JSON.stringify(belongsToLinksKeys)}`
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Type guard to check if the item being evaluated is the currentClass
|
|
193
|
-
* @param item
|
|
194
|
-
* @returns
|
|
179
|
+
* If the item has a JoinTable entry (is part of HasAndBelongsToMany relationship) then delete both JoinTable entries
|
|
180
|
+
* @param item - Denormalized record from HasAndBelongsToMany relationship
|
|
195
181
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
182
|
+
buildDeleteJoinTableLinkTransaction(item) {
|
|
183
|
+
const relMeta = this.#relationsLookup[item.type];
|
|
184
|
+
if ((0, utils_1.isHasAndBelongsToManyRelationship)(relMeta)) {
|
|
185
|
+
const belongsToLinksKeys = this.buildKeyObject(item, this.#sortKeyField, this.#partitionKeyField);
|
|
186
|
+
this.buildDeleteEntityTransaction(belongsToLinksKeys, {
|
|
187
|
+
errorMessage: `Failed to delete denormalized record with keys: ${JSON.stringify(belongsToLinksKeys)}`
|
|
188
|
+
});
|
|
189
|
+
}
|
|
198
190
|
}
|
|
199
191
|
/**
|
|
200
192
|
* Track validation errors and throw AggregateError after all validations have been run
|
|
@@ -203,5 +195,14 @@ class Delete extends OperationBase_1.default {
|
|
|
203
195
|
trackValidationError(err) {
|
|
204
196
|
this.#validationErrors.push(err);
|
|
205
197
|
}
|
|
198
|
+
buildKeyObject(item, pkField, skField) {
|
|
199
|
+
if ((0, utils_2.isKeyOfObject)(item, pkField) && (0, utils_2.isKeyOfObject)(item, skField)) {
|
|
200
|
+
return {
|
|
201
|
+
[this.#partitionKeyField]: item[pkField],
|
|
202
|
+
[this.#sortKeyField]: item[skField]
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
throw new Error("Invalid keys");
|
|
206
|
+
}
|
|
206
207
|
}
|
|
207
208
|
exports.default = Delete;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/operations/Delete/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/operations/Delete/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -36,33 +36,12 @@ declare class FindById<T extends DynaRecord> extends OperationBase<T> {
|
|
|
36
36
|
*/
|
|
37
37
|
private findByIdWithIncludes;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @param id
|
|
41
|
-
* @param
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
private buildFindByIdIncludesQuery;
|
|
45
|
-
/**
|
|
46
|
-
* Sort query results into an object containing:
|
|
47
|
-
* - item: The FindById DynamoItem
|
|
48
|
-
* - belongsToLinks: BelongsToLinkDynamoItem records for each of the included relationships
|
|
49
|
-
* @param queryResults
|
|
39
|
+
* Filters query results by parent entity and related entities for processing
|
|
40
|
+
* @param entityId - The id of the parent entity
|
|
41
|
+
* @param queryResults - The results of the query on the parent partition
|
|
50
42
|
* @returns
|
|
51
43
|
*/
|
|
52
44
|
private filterQueryResults;
|
|
53
|
-
private buildGetIncludedRelationshipsTransaction;
|
|
54
|
-
/**
|
|
55
|
-
* Builds transactions to get an associated entity via a BelongsToLink (HasOne or HasMany)
|
|
56
|
-
* @param belongsToLinks
|
|
57
|
-
* @param relationsLookup
|
|
58
|
-
*/
|
|
59
|
-
private buildGetRelationshipsThroughLinksTransaction;
|
|
60
|
-
/**
|
|
61
|
-
* Builds transactions to get an associated entity using a foreign key on the parent model (BelongsTo)
|
|
62
|
-
* @param belongsToLinks
|
|
63
|
-
* @param relationsLookup
|
|
64
|
-
*/
|
|
65
|
-
private buildGetRelationshipsThroughForeignKeyTransaction;
|
|
66
45
|
/**
|
|
67
46
|
* Get relationship metadata for the associations included in the query
|
|
68
47
|
* @param includedAssociations
|
|
@@ -70,10 +49,10 @@ declare class FindById<T extends DynaRecord> extends OperationBase<T> {
|
|
|
70
49
|
*/
|
|
71
50
|
private getIncludedRelationships;
|
|
72
51
|
/**
|
|
73
|
-
*
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
52
|
+
* Resolve query results into parent entity with included relationships
|
|
53
|
+
* @param parentEntity
|
|
54
|
+
* @param relatedEntities
|
|
55
|
+
* @param includedRelMeta
|
|
77
56
|
* @returns
|
|
78
57
|
*/
|
|
79
58
|
private resolveFindByIdIncludesResults;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FindById.d.ts","sourceRoot":"","sources":["../../../../src/operations/FindById/FindById.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"FindById.d.ts","sourceRoot":"","sources":["../../../../src/operations/FindById/FindById.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAI/C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAE7E,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EAGpB,MAAM,SAAS,CAAC;AAQjB;;;;;;GAMG;AACH,cAAM,QAAQ,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;;gBAG/C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAKlC;;;;;;;OAOG;IACU,GAAG,CACd,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAQpE;;;;OAIG;YACW,YAAY;IAmB1B;;;;;;OAMG;YACW,oBAAoB;IA4BlC;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAkB1B;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAchC;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IA0BtC;;;;;;;OAOG;IACH,OAAO,CAAC,+BAA+B;CAaxC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -3,16 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const metadata_1 = __importDefault(require("../../metadata"));
|
|
7
|
-
const dynamo_utils_1 = require("../../dynamo-utils");
|
|
8
|
-
const query_utils_1 = require("../../query-utils");
|
|
9
6
|
const Filters_1 = require("../../query-utils/Filters");
|
|
10
|
-
const
|
|
7
|
+
const dynamo_utils_1 = require("../../dynamo-utils");
|
|
11
8
|
const utils_1 = require("../../utils");
|
|
12
9
|
const OperationBase_1 = __importDefault(require("../OperationBase"));
|
|
13
10
|
const utils_2 = require("../utils");
|
|
14
11
|
const utils_3 = require("../../metadata/utils");
|
|
15
|
-
const Logger_1 = __importDefault(require("../../Logger"));
|
|
16
12
|
/**
|
|
17
13
|
* Facilitates the retrieval of an entity by its identifier (ID) from the database, potentially including its associated entities based on specified relationships.
|
|
18
14
|
*
|
|
@@ -24,7 +20,7 @@ class FindById extends OperationBase_1.default {
|
|
|
24
20
|
#transactionBuilder;
|
|
25
21
|
constructor(Entity) {
|
|
26
22
|
super(Entity);
|
|
27
|
-
this.#transactionBuilder = new
|
|
23
|
+
this.#transactionBuilder = new dynamo_utils_1.TransactGetBuilder();
|
|
28
24
|
}
|
|
29
25
|
/**
|
|
30
26
|
* Find an entity by Id and optionally include associations
|
|
@@ -72,107 +68,34 @@ class FindById extends OperationBase_1.default {
|
|
|
72
68
|
* @returns An entity with included associations serialized
|
|
73
69
|
*/
|
|
74
70
|
async findByIdWithIncludes(id, includedAssociations) {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const queryResults = await
|
|
78
|
-
|
|
79
|
-
ConsistentRead: true
|
|
71
|
+
const includedRelMeta = this.getIncludedRelationships(includedAssociations);
|
|
72
|
+
const includedTypesFilter = (0, Filters_1.includedRelationshipsFilter)(this.EntityClass.name, includedRelMeta);
|
|
73
|
+
const queryResults = await this.EntityClass.query(id, {
|
|
74
|
+
filter: includedTypesFilter
|
|
80
75
|
});
|
|
81
|
-
if (queryResults.length === 0)
|
|
76
|
+
if (queryResults.length === 0)
|
|
82
77
|
return undefined;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
const transactionRes = await this.#transactionBuilder.executeTransaction();
|
|
88
|
-
return this.resolveFindByIdIncludesResults(sortedQueryResults.item, transactionRes, relationsObj.relationsLookup);
|
|
78
|
+
const filtered = this.filterQueryResults(id, queryResults);
|
|
79
|
+
if (filtered.entity === undefined)
|
|
80
|
+
return;
|
|
81
|
+
return this.resolveFindByIdIncludesResults(filtered.entity, filtered.relatedEntities, includedRelMeta);
|
|
89
82
|
}
|
|
90
83
|
/**
|
|
91
|
-
*
|
|
92
|
-
* @param id
|
|
93
|
-
* @param
|
|
84
|
+
* Filters query results by parent entity and related entities for processing
|
|
85
|
+
* @param entityId - The id of the parent entity
|
|
86
|
+
* @param queryResults - The results of the query on the parent partition
|
|
94
87
|
* @returns
|
|
95
88
|
*/
|
|
96
|
-
|
|
97
|
-
const modelPartitionKey = this.tableMetadata.partitionKeyAttribute.name;
|
|
98
|
-
const partitionFilter = (0, Filters_1.includedRelationshipsFilter)(this.EntityClass.name, includedRelationships);
|
|
99
|
-
return new query_utils_1.QueryBuilder({
|
|
100
|
-
entityClassName: this.EntityClass.name,
|
|
101
|
-
key: { [modelPartitionKey]: this.EntityClass.partitionKeyValue(id) },
|
|
102
|
-
options: { filter: partitionFilter }
|
|
103
|
-
}).build();
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Sort query results into an object containing:
|
|
107
|
-
* - item: The FindById DynamoItem
|
|
108
|
-
* - belongsToLinks: BelongsToLinkDynamoItem records for each of the included relationships
|
|
109
|
-
* @param queryResults
|
|
110
|
-
* @returns
|
|
111
|
-
*/
|
|
112
|
-
filterQueryResults(queryResults) {
|
|
89
|
+
filterQueryResults(entityId, queryResults) {
|
|
113
90
|
return queryResults.reduce((acc, res) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
acc.item = res;
|
|
117
|
-
if ((0, utils_1.isBelongsToLinkDynamoItem)(res, this.tableMetadata))
|
|
118
|
-
acc.belongsToLinks.push(res);
|
|
119
|
-
return acc;
|
|
120
|
-
}, { item: {}, belongsToLinks: [] });
|
|
121
|
-
}
|
|
122
|
-
buildGetIncludedRelationshipsTransaction(sortedQueryResults, relationsObj) {
|
|
123
|
-
this.buildGetRelationshipsThroughLinksTransaction(sortedQueryResults.belongsToLinks, relationsObj.relationsLookup);
|
|
124
|
-
this.buildGetRelationshipsThroughForeignKeyTransaction(sortedQueryResults.item, relationsObj.belongsToRelationships);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Builds transactions to get an associated entity via a BelongsToLink (HasOne or HasMany)
|
|
128
|
-
* @param belongsToLinks
|
|
129
|
-
* @param relationsLookup
|
|
130
|
-
*/
|
|
131
|
-
buildGetRelationshipsThroughLinksTransaction(belongsToLinks, relationsLookup) {
|
|
132
|
-
const { name: tableName, defaultAttributes } = this.tableMetadata;
|
|
133
|
-
belongsToLinks.forEach(link => {
|
|
134
|
-
const foreignKey = link[defaultAttributes.foreignKey.alias];
|
|
135
|
-
const foreignEntityType = link[defaultAttributes.foreignEntityType.alias];
|
|
136
|
-
if ((0, utils_1.isPropertyKey)(foreignEntityType) && (0, utils_1.isString)(foreignKey)) {
|
|
137
|
-
const rel = relationsLookup[foreignEntityType];
|
|
138
|
-
this.#transactionBuilder.addGet({
|
|
139
|
-
TableName: tableName,
|
|
140
|
-
Key: {
|
|
141
|
-
[this.partitionKeyAlias]: rel.target.partitionKeyValue(foreignKey),
|
|
142
|
-
[this.sortKeyAlias]: rel.target.name
|
|
143
|
-
}
|
|
144
|
-
});
|
|
91
|
+
if (entityId === res.id) {
|
|
92
|
+
acc.entity = res;
|
|
145
93
|
}
|
|
146
94
|
else {
|
|
147
|
-
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
149
|
-
`Corrupted foreign key value. Invalid type. ${foreignEntityType} - ${foreignKey}`);
|
|
95
|
+
acc.relatedEntities.push(res);
|
|
150
96
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Builds transactions to get an associated entity using a foreign key on the parent model (BelongsTo)
|
|
155
|
-
* @param belongsToLinks
|
|
156
|
-
* @param relationsLookup
|
|
157
|
-
*/
|
|
158
|
-
buildGetRelationshipsThroughForeignKeyTransaction(item, belongsToRelationships) {
|
|
159
|
-
if (belongsToRelationships.length > 0) {
|
|
160
|
-
const { name: tableName } = this.tableMetadata;
|
|
161
|
-
const attributes = metadata_1.default.getEntityAttributes(this.EntityClass.name);
|
|
162
|
-
belongsToRelationships.forEach(rel => {
|
|
163
|
-
const foreignKeyTableAlias = attributes[rel.foreignKey].alias;
|
|
164
|
-
const foreignKeyVal = item[foreignKeyTableAlias];
|
|
165
|
-
if (foreignKeyVal === undefined)
|
|
166
|
-
return;
|
|
167
|
-
this.#transactionBuilder.addGet({
|
|
168
|
-
TableName: tableName,
|
|
169
|
-
Key: {
|
|
170
|
-
[this.partitionKeyAlias]: rel.target.partitionKeyValue(foreignKeyVal),
|
|
171
|
-
[this.sortKeyAlias]: rel.target.name
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
97
|
+
return acc;
|
|
98
|
+
}, { entity: undefined, relatedEntities: [] });
|
|
176
99
|
}
|
|
177
100
|
/**
|
|
178
101
|
* Get relationship metadata for the associations included in the query
|
|
@@ -189,35 +112,25 @@ class FindById extends OperationBase_1.default {
|
|
|
189
112
|
}, []);
|
|
190
113
|
}
|
|
191
114
|
/**
|
|
192
|
-
*
|
|
193
|
-
* @param
|
|
194
|
-
* @param
|
|
195
|
-
* @param
|
|
115
|
+
* Resolve query results into parent entity with included relationships
|
|
116
|
+
* @param parentEntity
|
|
117
|
+
* @param relatedEntities
|
|
118
|
+
* @param includedRelMeta
|
|
196
119
|
* @returns
|
|
197
120
|
*/
|
|
198
|
-
resolveFindByIdIncludesResults(
|
|
199
|
-
const
|
|
200
|
-
const typeAlias = this.tableMetadata.defaultAttributes.type.alias;
|
|
121
|
+
resolveFindByIdIncludesResults(parentEntity, relatedEntities, includedRelMeta) {
|
|
122
|
+
const { relationsLookup } = (0, utils_2.buildEntityRelationshipMetaObj)(includedRelMeta);
|
|
201
123
|
this.setIncludedRelationshipDefaults(parentEntity, relationsLookup);
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
const
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
Object.assign(parentEntity, { [rel.propertyName]: entities });
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
Object.assign(parentEntity, {
|
|
217
|
-
[rel.propertyName]: (0, utils_1.tableItemToEntity)(rel.target, tableItem)
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
124
|
+
relatedEntities.forEach(entity => {
|
|
125
|
+
const rel = relationsLookup[entity.type];
|
|
126
|
+
if (rel.type === "HasMany" || rel.type === "HasAndBelongsToMany") {
|
|
127
|
+
const entities = parentEntity[rel.propertyName];
|
|
128
|
+
if (Array.isArray(entities))
|
|
129
|
+
entities.push(entity);
|
|
130
|
+
Object.assign(parentEntity, { [rel.propertyName]: entities });
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
Object.assign(parentEntity, { [rel.propertyName]: entity });
|
|
221
134
|
}
|
|
222
135
|
});
|
|
223
136
|
return parentEntity;
|
|
@@ -232,8 +145,6 @@ class FindById extends OperationBase_1.default {
|
|
|
232
145
|
*/
|
|
233
146
|
setIncludedRelationshipDefaults(parentEntity, relationsLookup) {
|
|
234
147
|
Object.values(relationsLookup).forEach(rel => {
|
|
235
|
-
if (!(0, utils_1.isKeyOfEntity)(parentEntity, rel.propertyName))
|
|
236
|
-
return;
|
|
237
148
|
if ((0, utils_3.isHasManyRelationship)(rel) ||
|
|
238
149
|
(0, utils_3.isHasAndBelongsToManyRelationship)(rel)) {
|
|
239
150
|
(0, utils_1.safeAssign)(parentEntity, rel.propertyName, []);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { QueryItems } from "../../dynamo-utils";
|
|
2
1
|
import type DynaRecord from "../../DynaRecord";
|
|
3
|
-
import type {
|
|
4
|
-
import type
|
|
2
|
+
import type { EntityAttributesOnly, FunctionFields, RelationshipAttributeNames } from "../types";
|
|
3
|
+
import { type QueryResult, type QueryResults } from "../Query";
|
|
5
4
|
/**
|
|
6
5
|
* Defines options for the `FindById` operation, allowing specification of additional associations to include in the query result.
|
|
7
6
|
*
|
|
@@ -21,14 +20,14 @@ export interface FindByIdOptions<T extends DynaRecord> {
|
|
|
21
20
|
*/
|
|
22
21
|
export type IncludedAssociations<T extends DynaRecord> = NonNullable<FindByIdOptions<T>["include"]>;
|
|
23
22
|
/**
|
|
24
|
-
* Describes the structure of query results, sorting them into the main entity item and any associated
|
|
23
|
+
* Describes the structure of query results, sorting them into the main entity item and any associated items. Used during processing
|
|
25
24
|
*
|
|
26
25
|
* @property {QueryItems[number]} item - The main entity item retrieved from the query.
|
|
27
|
-
* @property {
|
|
26
|
+
* @property {QueryItems[]} relatedEntities - An array of `denormalized records` instances associated with the main entity item.
|
|
28
27
|
*/
|
|
29
28
|
export interface SortedQueryResults {
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
entity?: QueryResult<DynaRecord>;
|
|
30
|
+
relatedEntities: QueryResults<DynaRecord>;
|
|
32
31
|
}
|
|
33
32
|
/**
|
|
34
33
|
* Derives the keys of included associations from `FindByIdOptions`, representing the names of relationships specified to be included in the query result.
|
|
@@ -44,7 +43,7 @@ type IncludedKeys<T extends DynaRecord, Opts extends FindByIdOptions<T>> = Opts
|
|
|
44
43
|
* @template P - The properties of the entity `T`.
|
|
45
44
|
*/
|
|
46
45
|
type EntityKeysWithIncludedAssociations<T extends DynaRecord, P extends keyof T> = {
|
|
47
|
-
[K in P]: T[K] extends DynaRecord ?
|
|
46
|
+
[K in P]: T[K] extends DynaRecord ? EntityAttributesOnly<T> : T[K] extends DynaRecord[] ? Array<EntityAttributesOnly<T[K][number]>> : T[K];
|
|
48
47
|
};
|
|
49
48
|
/**
|
|
50
49
|
* Represents the result of a `FindById` operation, including the main entity and any specified associated entities.
|
|
@@ -52,6 +51,6 @@ type EntityKeysWithIncludedAssociations<T extends DynaRecord, P extends keyof T>
|
|
|
52
51
|
* @template T - The type of the main entity, extending `DynaRecord`.
|
|
53
52
|
* @template Opts - The options for the `FindById` operation, specifying included associations.
|
|
54
53
|
*/
|
|
55
|
-
export type FindByIdIncludesRes<T extends DynaRecord, Opts extends FindByIdOptions<T>> = EntityKeysWithIncludedAssociations<T, keyof
|
|
54
|
+
export type FindByIdIncludesRes<T extends DynaRecord, Opts extends FindByIdOptions<T>> = EntityKeysWithIncludedAssociations<T, keyof EntityAttributesOnly<T> | IncludedKeys<T, Opts> | FunctionFields<T>>;
|
|
56
55
|
export {};
|
|
57
56
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/operations/FindById/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/operations/FindById/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,0BAA0B,EAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,UAAU;IACnD,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC,CAAC;CACjE;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,UAAU,IAAI,WAAW,CAClE,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACjC,eAAe,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;CAC3C;AAED;;;;;GAKG;AACH,KAAK,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,SAAS,eAAe,CAAC,CAAC,CAAC,IACrE,IAAI,SAAS,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GACrC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,GACxD,KAAK,CAAC;AAEZ;;;;;GAKG;AACH,KAAK,kCAAkC,CACrC,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,MAAM,CAAC,IACf;KACD,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,UAAU,GAC7B,oBAAoB,CAAC,CAAC,CAAC,GACvB,CAAC,CAAC,CAAC,CAAC,SAAS,UAAU,EAAE,GACvB,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GACzC,CAAC,CAAC,CAAC,CAAC;CACX,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,CAC7B,CAAC,SAAS,UAAU,EACpB,IAAI,SAAS,eAAe,CAAC,CAAC,CAAC,IAC7B,kCAAkC,CACpC,CAAC,EACD,MAAM,oBAAoB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAC1E,CAAC"}
|
|
@@ -14,7 +14,7 @@ declare class Query<T extends DynaRecord> extends OperationBase<T> {
|
|
|
14
14
|
* Run the query operation
|
|
15
15
|
* @param key EntityId or object with PartitionKey and optional SortKey conditions
|
|
16
16
|
* @param options Filter conditions, indexName, or SortKey conditions if querying by keys
|
|
17
|
-
* @returns Array of Entity or
|
|
17
|
+
* @returns Array of Entity or denormalized records
|
|
18
18
|
*/
|
|
19
19
|
run(key: string | EntityKeyConditions<T>, options?: QueryBuilderOptions | Omit<QueryOptions, "indexName">): Promise<QueryResults<T>>;
|
|
20
20
|
/**
|
|
@@ -40,6 +40,7 @@ declare class Query<T extends DynaRecord> extends OperationBase<T> {
|
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
42
|
private resolveQueryResults;
|
|
43
|
+
private tableItemToLinkedEntity;
|
|
43
44
|
}
|
|
44
45
|
export default Query;
|
|
45
46
|
//# sourceMappingURL=Query.d.ts.map
|