| 5 | export type KeyComparator = '=' | '<' | '>' | '<=' | '>='; |
| 6 | |
| 7 | export class Query extends Search { |
| 8 | private keyCondition = new ConditionExpression(); |
| 9 | scanIndexForward?: boolean = undefined; |
| 10 | |
| 11 | keyBetween(path: string, lower: any, upper: any) { this.keyCondition.between(path, lower, upper); return this; } |
| 12 | keyBeginsWith(name: string, value: any) { this.keyCondition.beginsWith(name, value); return this; } |
| 13 | async run() { return await this._client!.send(new QueryCommand(this.build())); } |
| 14 | |
| 15 | key(name: string, comparator: KeyComparator, value: any) { |
| 16 | const suffix = ConditionExpression.suffixForComparator(comparator); |
| 17 | this.keyCondition.pair(name, value, (nameKey, valueKey) => { return `${nameKey} ${comparator} ${valueKey}`; }, suffix); |
| 18 | return this; |
| 19 | } |
| 20 | |
| 21 | build(): QueryCommandInput { |
| 22 | const base: QueryCommandInput = super.build(); |
| 23 | if (this.scanIndexForward !== undefined) { base.ScanIndexForward = this.scanIndexForward; } |
| 24 | if (!this.keyCondition.isEmpty()) { |
| 25 | base.KeyConditionExpression = this.keyCondition.expression; |
| 26 | base.ExpressionAttributeNames = { ...base.ExpressionAttributeNames, ...this.keyCondition.names, }; |
| 27 | base.ExpressionAttributeValues = { ...base.ExpressionAttributeValues, ...this.keyCondition.values, }; |
| 28 | } |
| 29 | return base; |
| 30 | } |
| 31 | } |
nothing calls this directly
no outgoing calls
no test coverage detected