@better-giving/donation 3.0.23 → 3.0.25
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/donations-db.d.mts +1 -0
- package/dist/donations-db.mjs +14 -2
- package/package.json +2 -2
- package/src/donations-db.mts +18 -2
package/dist/donations-db.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class DonationsDb extends Db {
|
|
|
13
13
|
};
|
|
14
14
|
item(id: string): Promise<IDonationFinal | undefined>;
|
|
15
15
|
put_txi(data: IDonationFinalAttr): TxType["Put"];
|
|
16
|
+
update(id: string, data: Partial<Omit<IDonationFinalAttr, "transactionId">>): Promise<IDonationFinal>;
|
|
16
17
|
referred_by_q(referrer: string, opts?: IPageOpts): QueryCommandInput;
|
|
17
18
|
referred_by(referrer: string, opts?: IPageOpts): Promise<IPageKeyed<IDonationFinal>>;
|
|
18
19
|
list_to_npo(npo: number, opts?: IDonationsSearch & {
|
package/dist/donations-db.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GetCommand,
|
|
2
|
-
import { Db } from "@better-giving/db";
|
|
1
|
+
import { GetCommand, QueryCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
|
|
2
|
+
import { Db, UpdateBuilder } from "@better-giving/db";
|
|
3
3
|
export class DonationsDb extends Db {
|
|
4
4
|
static gsi_referrer$settled_date = "Referrer-FinalizedDate_Index";
|
|
5
5
|
static gsi_npo$settled_date = "npo-settled_date-gsi";
|
|
@@ -24,6 +24,18 @@ export class DonationsDb extends Db {
|
|
|
24
24
|
ConditionExpression: `attribute_not_exists(${"transactionId"})`,
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
async update(id, data) {
|
|
28
|
+
const upd8 = new UpdateBuilder();
|
|
29
|
+
for (const k in data) {
|
|
30
|
+
upd8.set(k, data[k]);
|
|
31
|
+
}
|
|
32
|
+
const cmd = new UpdateCommand({
|
|
33
|
+
TableName: this.table,
|
|
34
|
+
Key: this.key(id),
|
|
35
|
+
...upd8.collect(),
|
|
36
|
+
});
|
|
37
|
+
return this.client.send(cmd).then((r) => r.Attributes);
|
|
38
|
+
}
|
|
27
39
|
referred_by_q(referrer, opts) {
|
|
28
40
|
const q = {
|
|
29
41
|
TableName: this.table,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-giving/donation",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.25",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@better-giving/config": "1.1.2"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@better-giving/types": "1.1.8",
|
|
9
|
-
"@better-giving/db": "2.0.
|
|
9
|
+
"@better-giving/db": "2.0.7",
|
|
10
10
|
"@better-giving/schemas": "2.0.4",
|
|
11
11
|
"@aws-sdk/lib-dynamodb": "3.485.0",
|
|
12
12
|
"valibot": "0.42.0",
|
package/src/donations-db.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GetCommand,
|
|
3
|
-
PutCommand,
|
|
4
3
|
QueryCommand,
|
|
4
|
+
UpdateCommand,
|
|
5
5
|
type QueryCommandInput,
|
|
6
6
|
} from "@aws-sdk/lib-dynamodb";
|
|
7
|
-
import { Db, type TxType } from "@better-giving/db";
|
|
7
|
+
import { Db, UpdateBuilder, type TxType } from "@better-giving/db";
|
|
8
8
|
import type { IPageKeyed } from "@better-giving/types/api";
|
|
9
9
|
import type { IDonationFinal, IDonationFinalAttr } from "./interfaces.mjs";
|
|
10
10
|
import type { IDonationsSearch, IPageOpts } from "./schema.mjs";
|
|
@@ -43,6 +43,22 @@ export class DonationsDb extends Db {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
async update(
|
|
47
|
+
id: string,
|
|
48
|
+
data: Partial<Omit<IDonationFinalAttr, "transactionId">>
|
|
49
|
+
): Promise<IDonationFinal> {
|
|
50
|
+
const upd8 = new UpdateBuilder();
|
|
51
|
+
for (const k in data) {
|
|
52
|
+
upd8.set(k , (data as any)[k]);
|
|
53
|
+
}
|
|
54
|
+
const cmd = new UpdateCommand({
|
|
55
|
+
TableName: this.table,
|
|
56
|
+
Key: this.key(id),
|
|
57
|
+
...upd8.collect(),
|
|
58
|
+
});
|
|
59
|
+
return this.client.send(cmd).then((r) => r.Attributes as any);
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
referred_by_q(referrer: string, opts?: IPageOpts) {
|
|
47
63
|
const q: QueryCommandInput = {
|
|
48
64
|
TableName: this.table,
|