rajt 0.0.48 → 0.0.49
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/dynamodb/client.ts +11 -6
- package/src/dynamodb/model.ts +1 -4
package/package.json
CHANGED
package/src/dynamodb/client.ts
CHANGED
|
@@ -45,18 +45,18 @@ export class Dynamodb {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export class RawClient {
|
|
48
|
-
static async get(TableName: string, key: Keys, sk?: string) {
|
|
48
|
+
static async get(TableName: string, key: Keys | Record<string, string>, sk?: string) {
|
|
49
49
|
return DocumentClient.send(new GetCommand({
|
|
50
50
|
TableName,
|
|
51
51
|
Key: this.#key(key, sk),
|
|
52
52
|
}))
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
static async scan(TableName: string, filters: ScanCommandInput) {
|
|
55
|
+
static async scan(TableName: string, filters: Omit<ScanCommandInput, 'TableName'>) {
|
|
56
56
|
return DocumentClient.send(new ScanCommand({ ...filters, TableName }))
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
static async query(TableName: string, filters: QueryCommandInput) {
|
|
59
|
+
static async query(TableName: string, filters: Omit<QueryCommandInput, 'TableName'>) {
|
|
60
60
|
return DocumentClient.send(new QueryCommand({ ...filters, TableName }))
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -64,13 +64,18 @@ export class RawClient {
|
|
|
64
64
|
return DocumentClient.send(new PutCommand({ TableName, Item }))
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
static async update(
|
|
67
|
+
static async update(
|
|
68
|
+
TableName: string,
|
|
69
|
+
filters: Omit<UpdateCommandInput, 'TableName' | 'Key'>,
|
|
70
|
+
key: Keys | Record<string, string>,
|
|
71
|
+
sk?: string
|
|
72
|
+
) {
|
|
68
73
|
return DocumentClient.send(new UpdateCommand({
|
|
69
74
|
...filters, TableName, Key: this.#key(key, sk),
|
|
70
75
|
}))
|
|
71
76
|
}
|
|
72
77
|
|
|
73
|
-
static async delete(TableName: string, key: Keys, sk?: string) {
|
|
78
|
+
static async delete(TableName: string, key: Keys | Record<string, string>, sk?: string) {
|
|
74
79
|
return DocumentClient.send(new DeleteCommand({ TableName, Key: this.#key(key, sk) }))
|
|
75
80
|
}
|
|
76
81
|
|
|
@@ -82,7 +87,7 @@ export class RawClient {
|
|
|
82
87
|
return DocumentClient.send(new BatchWriteCommand(batch))
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
static #key(key: Keys, sk?: string) {
|
|
90
|
+
static #key(key: Keys | Record<string, string>, sk?: string) {
|
|
86
91
|
if (typeof key == 'object' && key != null) return key
|
|
87
92
|
|
|
88
93
|
let pk: string
|
package/src/dynamodb/model.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UpdateCommandInput,
|
|
3
|
-
} from '@aws-sdk/lib-dynamodb'
|
|
4
1
|
import type { ModelMetadata, Keys, Model, Filter } from './types'
|
|
5
2
|
import { getModelMetadata } from './decorators'
|
|
6
3
|
import QueryBuilder from './query-builder'
|
|
@@ -121,7 +118,7 @@ export default class AbstractModel<T extends object> {
|
|
|
121
118
|
UpdateExpression,
|
|
122
119
|
ExpressionAttributeValues,
|
|
123
120
|
ExpressionAttributeNames,
|
|
124
|
-
}
|
|
121
|
+
}, key)
|
|
125
122
|
|
|
126
123
|
return this.#processItem(attrs, keys)
|
|
127
124
|
}
|