@better-giving/endowment 4.0.13 → 4.0.14
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/db.d.mts +1 -0
- package/dist/db.mjs +15 -1
- package/dist/db2.d.mts +1 -0
- package/dist/db2.mjs +1 -0
- package/package.json +2 -2
- package/src/db.mts +19 -0
package/dist/db.d.mts
CHANGED
|
@@ -37,6 +37,7 @@ export declare class NpoDb extends Db {
|
|
|
37
37
|
gsi1PK: string;
|
|
38
38
|
gsi1SK: string;
|
|
39
39
|
};
|
|
40
|
+
npos_get<T extends TNpoDbKeys[]>(ids: number[], fields?: T): Promise<TNpoDbProjectedTo<T>[]>;
|
|
40
41
|
npo_count_inc(): Promise<number>;
|
|
41
42
|
npo_media(npo: number, opts: IMediaSearchObj): Promise<IMediaPage>;
|
|
42
43
|
npo_referred_by(id: string): Promise<INpoReferredBy[]>;
|
package/dist/db.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeleteCommand, GetCommand, PutCommand, QueryCommand, TransactWriteCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
|
|
1
|
+
import { BatchGetCommand, DeleteCommand, GetCommand, PutCommand, QueryCommand, TransactWriteCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
|
|
2
2
|
import { Db, Txs, UpdateBuilder } from "@better-giving/db";
|
|
3
3
|
import KSUID from "ksuid";
|
|
4
4
|
import { med_key_filter, med_sk, to_imedia } from "./media.mjs";
|
|
@@ -55,6 +55,20 @@ export class NpoDb extends Db {
|
|
|
55
55
|
gsi1SK: med_sk(id, type, featured),
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
+
async npos_get(ids, fields) {
|
|
59
|
+
const { names, expression } = projection(fields);
|
|
60
|
+
const batch_get = new BatchGetCommand({
|
|
61
|
+
RequestItems: {
|
|
62
|
+
[NpoDb.name]: {
|
|
63
|
+
Keys: ids.map((id) => this.key_npo(id)),
|
|
64
|
+
ProjectionExpression: expression,
|
|
65
|
+
ExpressionAttributeNames: names,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
const { Responses } = await this.client.send(batch_get);
|
|
70
|
+
return (Responses?.[NpoDb.name] ?? []);
|
|
71
|
+
}
|
|
58
72
|
async npo_count_inc() {
|
|
59
73
|
const cmd = new UpdateCommand({
|
|
60
74
|
TableName: NpoDb.name,
|
package/dist/db2.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/db2.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-giving/endowment",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.14",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"ksuid": "3.0.0"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@better-giving/schemas": "2.0.0",
|
|
9
9
|
"@better-giving/types": "1.1.8",
|
|
10
|
-
"@better-giving/db": "2.0.
|
|
10
|
+
"@better-giving/db": "2.0.1",
|
|
11
11
|
"@aws-sdk/lib-dynamodb": "3.485.0",
|
|
12
12
|
"valibot": "0.42.0"
|
|
13
13
|
},
|
package/src/db.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BatchGetCommand,
|
|
2
3
|
DeleteCommand,
|
|
3
4
|
GetCommand,
|
|
4
5
|
PutCommand,
|
|
@@ -94,6 +95,24 @@ export class NpoDb extends Db {
|
|
|
94
95
|
};
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
async npos_get<T extends TNpoDbKeys[]>(
|
|
99
|
+
ids: number[],
|
|
100
|
+
fields?: T
|
|
101
|
+
): Promise<TNpoDbProjectedTo<T>[]> {
|
|
102
|
+
const { names, expression } = projection(fields);
|
|
103
|
+
const batch_get = new BatchGetCommand({
|
|
104
|
+
RequestItems: {
|
|
105
|
+
[NpoDb.name]: {
|
|
106
|
+
Keys: ids.map((id) => this.key_npo(id)),
|
|
107
|
+
ProjectionExpression: expression,
|
|
108
|
+
ExpressionAttributeNames: names,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
const { Responses } = await this.client.send(batch_get);
|
|
113
|
+
return (Responses?.[NpoDb.name] ?? []) as any;
|
|
114
|
+
}
|
|
115
|
+
|
|
97
116
|
async npo_count_inc(): Promise<number> {
|
|
98
117
|
const cmd = new UpdateCommand({
|
|
99
118
|
TableName: NpoDb.name,
|