@better-giving/endowment 4.0.15 → 4.0.16
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 -1
- package/dist/db.mjs +28 -28
- package/package.json +1 -1
- package/src/db.mts +28 -28
package/dist/db.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { Db, type UpdateComps } from "@better-giving/db";
|
|
|
2
2
|
import type { IMedia, IMediaPage, INpoReferredBy, INpoWithRegNum, INpoWithRid, TBinFlag, TNpoDbKeys, TNpoDbProjectedTo } from "./interfaces.mjs";
|
|
3
3
|
import type { IMediaSearchObj, IMediaUpdate, IMilestone, IMilestoneNew, IMilestoneUpdate, INpo, INpoUpdate, IProgram, IProgramDb, IProgramNew, IProgramUpdate, TMediaType } from "./schema.mjs";
|
|
4
4
|
export declare class NpoDb extends Db {
|
|
5
|
-
static readonly
|
|
5
|
+
static readonly table = "endowments_v3";
|
|
6
6
|
static readonly slug_env_gsi: "slug-env-gsi";
|
|
7
7
|
static readonly regnum_env_gsi: "regnum-env-gsi";
|
|
8
8
|
key_npo(id: number): {
|
package/dist/db.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import KSUID from "ksuid";
|
|
|
4
4
|
import { med_key_filter, med_sk, to_imedia } from "./media.mjs";
|
|
5
5
|
import { projection } from "./npo.mjs";
|
|
6
6
|
export class NpoDb extends Db {
|
|
7
|
-
static
|
|
7
|
+
static table = "endowments_v3";
|
|
8
8
|
static slug_env_gsi = "slug-env-gsi";
|
|
9
9
|
static regnum_env_gsi = "regnum-env-gsi";
|
|
10
10
|
key_npo(id) {
|
|
@@ -57,22 +57,22 @@ export class NpoDb extends Db {
|
|
|
57
57
|
}
|
|
58
58
|
async npos_get(ids, fields) {
|
|
59
59
|
const { names, expression } = projection(fields);
|
|
60
|
-
const
|
|
60
|
+
const cmd = new BatchGetCommand({
|
|
61
61
|
RequestItems: {
|
|
62
|
-
[NpoDb.
|
|
62
|
+
[NpoDb.table]: {
|
|
63
63
|
Keys: ids.map((id) => this.key_npo(id)),
|
|
64
64
|
ProjectionExpression: expression,
|
|
65
65
|
ExpressionAttributeNames: names,
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
|
-
const { Responses } = await this.client.send(
|
|
70
|
-
const x = Responses?.[NpoDb.
|
|
69
|
+
const { Responses } = await this.client.send(cmd);
|
|
70
|
+
const x = Responses?.[NpoDb.table] ?? [];
|
|
71
71
|
return x.map((i) => this.sans_keys(i));
|
|
72
72
|
}
|
|
73
73
|
async npo_count_inc() {
|
|
74
74
|
const cmd = new UpdateCommand({
|
|
75
|
-
TableName: NpoDb.
|
|
75
|
+
TableName: NpoDb.table,
|
|
76
76
|
Key: this.key_count,
|
|
77
77
|
UpdateExpression: "SET #count = #count + :one",
|
|
78
78
|
ExpressionAttributeNames: {
|
|
@@ -88,7 +88,7 @@ export class NpoDb extends Db {
|
|
|
88
88
|
const PK = this.key_npo_med("ksuid-sk", npo).PK;
|
|
89
89
|
const [expression, values] = med_key_filter(PK, opts);
|
|
90
90
|
const cmd = new QueryCommand({
|
|
91
|
-
TableName: NpoDb.
|
|
91
|
+
TableName: NpoDb.table,
|
|
92
92
|
IndexName: "gsi1",
|
|
93
93
|
Limit: opts.limit,
|
|
94
94
|
KeyConditionExpression: expression,
|
|
@@ -101,7 +101,7 @@ export class NpoDb extends Db {
|
|
|
101
101
|
}
|
|
102
102
|
async npo_referred_by(id) {
|
|
103
103
|
const cmd = new QueryCommand({
|
|
104
|
-
TableName: NpoDb.
|
|
104
|
+
TableName: NpoDb.table,
|
|
105
105
|
IndexName: "gsi1",
|
|
106
106
|
KeyConditionExpression: "#pk = :pk",
|
|
107
107
|
ExpressionAttributeValues: {
|
|
@@ -114,7 +114,7 @@ export class NpoDb extends Db {
|
|
|
114
114
|
}
|
|
115
115
|
async npo_with_rid(id) {
|
|
116
116
|
const cmd = new QueryCommand({
|
|
117
|
-
TableName: NpoDb.
|
|
117
|
+
TableName: NpoDb.table,
|
|
118
118
|
IndexName: "gsi2",
|
|
119
119
|
KeyConditionExpression: "gsi2PK = :pk",
|
|
120
120
|
ExpressionAttributeValues: {
|
|
@@ -128,7 +128,7 @@ export class NpoDb extends Db {
|
|
|
128
128
|
}
|
|
129
129
|
async npo_with_regnum(regnum, country = "United States") {
|
|
130
130
|
const cmd = new QueryCommand({
|
|
131
|
-
TableName: NpoDb.
|
|
131
|
+
TableName: NpoDb.table,
|
|
132
132
|
IndexName: NpoDb.regnum_env_gsi,
|
|
133
133
|
Limit: 1,
|
|
134
134
|
KeyConditionExpression: "#rn = :rn AND #env = :env",
|
|
@@ -188,7 +188,7 @@ export class NpoDb extends Db {
|
|
|
188
188
|
featured: false,
|
|
189
189
|
});
|
|
190
190
|
const command = new PutCommand({
|
|
191
|
-
TableName: NpoDb.
|
|
191
|
+
TableName: NpoDb.table,
|
|
192
192
|
Item: item,
|
|
193
193
|
});
|
|
194
194
|
await this.client.send(command);
|
|
@@ -196,7 +196,7 @@ export class NpoDb extends Db {
|
|
|
196
196
|
}
|
|
197
197
|
async npo_med(npo, mid) {
|
|
198
198
|
const cmd = new GetCommand({
|
|
199
|
-
TableName: NpoDb.
|
|
199
|
+
TableName: NpoDb.table,
|
|
200
200
|
Key: this.key_npo_med(mid, npo),
|
|
201
201
|
});
|
|
202
202
|
const { Item: i } = await this.client.send(cmd);
|
|
@@ -205,7 +205,7 @@ export class NpoDb extends Db {
|
|
|
205
205
|
async npo_med_update(npo, prev, update) {
|
|
206
206
|
const new_sk = med_sk(prev.id, prev.type, (update.featured ?? prev.featured) ? "0" : "1");
|
|
207
207
|
const cmd = new UpdateCommand({
|
|
208
|
-
TableName: NpoDb.
|
|
208
|
+
TableName: NpoDb.table,
|
|
209
209
|
Key: this.key_npo_med(prev.id, npo),
|
|
210
210
|
UpdateExpression: "SET #url = :url, gsi1SK = :gsi1SK",
|
|
211
211
|
ExpressionAttributeNames: { "#url": "url" },
|
|
@@ -219,7 +219,7 @@ export class NpoDb extends Db {
|
|
|
219
219
|
}
|
|
220
220
|
async npo_med_delete(npo, mid) {
|
|
221
221
|
const cmd = new DeleteCommand({
|
|
222
|
-
TableName: NpoDb.
|
|
222
|
+
TableName: NpoDb.table,
|
|
223
223
|
Key: this.key_npo_med(mid, npo),
|
|
224
224
|
});
|
|
225
225
|
return this.client.send(cmd);
|
|
@@ -228,7 +228,7 @@ export class NpoDb extends Db {
|
|
|
228
228
|
const { names, expression } = projection(fields);
|
|
229
229
|
if (typeof id === "string") {
|
|
230
230
|
const cmd = new QueryCommand({
|
|
231
|
-
TableName: NpoDb.
|
|
231
|
+
TableName: NpoDb.table,
|
|
232
232
|
IndexName: NpoDb.slug_env_gsi,
|
|
233
233
|
KeyConditionExpression: "#slug = :slug and #env = :env",
|
|
234
234
|
ExpressionAttributeValues: {
|
|
@@ -246,7 +246,7 @@ export class NpoDb extends Db {
|
|
|
246
246
|
return x ? this.sans_keys(x) : undefined;
|
|
247
247
|
}
|
|
248
248
|
const cmd = new GetCommand({
|
|
249
|
-
TableName: NpoDb.
|
|
249
|
+
TableName: NpoDb.table,
|
|
250
250
|
Key: this.key_npo(id),
|
|
251
251
|
ProjectionExpression: expression,
|
|
252
252
|
ExpressionAttributeNames: names,
|
|
@@ -280,7 +280,7 @@ export class NpoDb extends Db {
|
|
|
280
280
|
async npo_update(id, update) {
|
|
281
281
|
const upd8 = this.npo_update_comps(update);
|
|
282
282
|
const cmd = new UpdateCommand({
|
|
283
|
-
TableName: NpoDb.
|
|
283
|
+
TableName: NpoDb.table,
|
|
284
284
|
Key: this.key_npo(id),
|
|
285
285
|
...upd8,
|
|
286
286
|
ReturnValues: "ALL_NEW",
|
|
@@ -289,7 +289,7 @@ export class NpoDb extends Db {
|
|
|
289
289
|
}
|
|
290
290
|
async prog_milestones(id) {
|
|
291
291
|
const command = new QueryCommand({
|
|
292
|
-
TableName: NpoDb.
|
|
292
|
+
TableName: NpoDb.table,
|
|
293
293
|
KeyConditionExpression: `PK = :PK`,
|
|
294
294
|
ExpressionAttributeValues: {
|
|
295
295
|
":PK": this.key_prog_milestone("not-used", id).PK,
|
|
@@ -301,7 +301,7 @@ export class NpoDb extends Db {
|
|
|
301
301
|
}
|
|
302
302
|
async prog_milestone_delete(pid, mid) {
|
|
303
303
|
const cmd = new DeleteCommand({
|
|
304
|
-
TableName: NpoDb.
|
|
304
|
+
TableName: NpoDb.table,
|
|
305
305
|
Key: this.key_prog_milestone(mid, pid),
|
|
306
306
|
});
|
|
307
307
|
return this.client.send(cmd);
|
|
@@ -309,7 +309,7 @@ export class NpoDb extends Db {
|
|
|
309
309
|
async prog_milestone_put(pid, content) {
|
|
310
310
|
const item = this.prog_milestone_record(pid, content);
|
|
311
311
|
const cmd = new PutCommand({
|
|
312
|
-
TableName: NpoDb.
|
|
312
|
+
TableName: NpoDb.table,
|
|
313
313
|
Item: item,
|
|
314
314
|
});
|
|
315
315
|
return this.client.send(cmd).then(() => item.id);
|
|
@@ -320,7 +320,7 @@ export class NpoDb extends Db {
|
|
|
320
320
|
upd8.set(key, value);
|
|
321
321
|
}
|
|
322
322
|
const cmd = new UpdateCommand({
|
|
323
|
-
TableName: NpoDb.
|
|
323
|
+
TableName: NpoDb.table,
|
|
324
324
|
Key: this.key_prog_milestone(mid, pid),
|
|
325
325
|
...upd8.collect(),
|
|
326
326
|
ReturnValues: "ALL_NEW",
|
|
@@ -329,7 +329,7 @@ export class NpoDb extends Db {
|
|
|
329
329
|
}
|
|
330
330
|
async npo_program(id, npo_id) {
|
|
331
331
|
const cmd = new GetCommand({
|
|
332
|
-
TableName: NpoDb.
|
|
332
|
+
TableName: NpoDb.table,
|
|
333
333
|
Key: this.key_npo_program(id, npo_id),
|
|
334
334
|
});
|
|
335
335
|
const { Item: p } = await this.client.send(cmd);
|
|
@@ -343,7 +343,7 @@ export class NpoDb extends Db {
|
|
|
343
343
|
}
|
|
344
344
|
async npo_programs(id) {
|
|
345
345
|
const cmd = new QueryCommand({
|
|
346
|
-
TableName: NpoDb.
|
|
346
|
+
TableName: NpoDb.table,
|
|
347
347
|
KeyConditionExpression: `PK = :PK and begins_with(SK, :SK)`,
|
|
348
348
|
ExpressionAttributeValues: {
|
|
349
349
|
":PK": this.key_npo_program("not-used", id).PK,
|
|
@@ -363,12 +363,12 @@ export class NpoDb extends Db {
|
|
|
363
363
|
totalDonations: 0,
|
|
364
364
|
});
|
|
365
365
|
txs.put({
|
|
366
|
-
TableName: NpoDb.
|
|
366
|
+
TableName: NpoDb.table,
|
|
367
367
|
Item: db_prog,
|
|
368
368
|
});
|
|
369
369
|
for (const m of milestones || []) {
|
|
370
370
|
txs.put({
|
|
371
|
-
TableName: NpoDb.
|
|
371
|
+
TableName: NpoDb.table,
|
|
372
372
|
Item: this.prog_milestone_record(pid, m),
|
|
373
373
|
});
|
|
374
374
|
}
|
|
@@ -382,12 +382,12 @@ export class NpoDb extends Db {
|
|
|
382
382
|
const milestones = await this.prog_milestones(prog);
|
|
383
383
|
const txs = new Txs();
|
|
384
384
|
txs.del({
|
|
385
|
-
TableName: NpoDb.
|
|
385
|
+
TableName: NpoDb.table,
|
|
386
386
|
Key: this.key_npo_program(prog, npo),
|
|
387
387
|
});
|
|
388
388
|
for (const m of milestones) {
|
|
389
389
|
txs.del({
|
|
390
|
-
TableName: NpoDb.
|
|
390
|
+
TableName: NpoDb.table,
|
|
391
391
|
Key: this.key_prog_milestone(m.id, prog),
|
|
392
392
|
});
|
|
393
393
|
}
|
|
@@ -402,7 +402,7 @@ export class NpoDb extends Db {
|
|
|
402
402
|
upd8.set(key, value);
|
|
403
403
|
}
|
|
404
404
|
const cmd = new UpdateCommand({
|
|
405
|
-
TableName: NpoDb.
|
|
405
|
+
TableName: NpoDb.table,
|
|
406
406
|
Key: this.key_npo_program(prog, npo),
|
|
407
407
|
...upd8.collect(),
|
|
408
408
|
ReturnValues: "ALL_NEW",
|
package/package.json
CHANGED
package/src/db.mts
CHANGED
|
@@ -38,7 +38,7 @@ import type {
|
|
|
38
38
|
} from "./schema.mjs";
|
|
39
39
|
|
|
40
40
|
export class NpoDb extends Db {
|
|
41
|
-
static
|
|
41
|
+
static readonly table = "endowments_v3";
|
|
42
42
|
static readonly slug_env_gsi = "slug-env-gsi" as const;
|
|
43
43
|
static readonly regnum_env_gsi = "regnum-env-gsi" as const;
|
|
44
44
|
key_npo(id: number) {
|
|
@@ -100,23 +100,23 @@ export class NpoDb extends Db {
|
|
|
100
100
|
fields?: T
|
|
101
101
|
): Promise<TNpoDbProjectedTo<T>[]> {
|
|
102
102
|
const { names, expression } = projection(fields);
|
|
103
|
-
const
|
|
103
|
+
const cmd = new BatchGetCommand({
|
|
104
104
|
RequestItems: {
|
|
105
|
-
[NpoDb.
|
|
105
|
+
[NpoDb.table]: {
|
|
106
106
|
Keys: ids.map((id) => this.key_npo(id)),
|
|
107
107
|
ProjectionExpression: expression,
|
|
108
108
|
ExpressionAttributeNames: names,
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
111
|
});
|
|
112
|
-
const { Responses } = await this.client.send(
|
|
113
|
-
const x = Responses?.[NpoDb.
|
|
112
|
+
const { Responses } = await this.client.send(cmd);
|
|
113
|
+
const x = Responses?.[NpoDb.table] ?? [];
|
|
114
114
|
return x.map((i) => this.sans_keys(i));
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
async npo_count_inc(): Promise<number> {
|
|
118
118
|
const cmd = new UpdateCommand({
|
|
119
|
-
TableName: NpoDb.
|
|
119
|
+
TableName: NpoDb.table,
|
|
120
120
|
Key: this.key_count,
|
|
121
121
|
UpdateExpression: "SET #count = #count + :one",
|
|
122
122
|
ExpressionAttributeNames: {
|
|
@@ -135,7 +135,7 @@ export class NpoDb extends Db {
|
|
|
135
135
|
const [expression, values] = med_key_filter(PK, opts);
|
|
136
136
|
|
|
137
137
|
const cmd = new QueryCommand({
|
|
138
|
-
TableName: NpoDb.
|
|
138
|
+
TableName: NpoDb.table,
|
|
139
139
|
IndexName: "gsi1",
|
|
140
140
|
Limit: opts.limit,
|
|
141
141
|
KeyConditionExpression: expression,
|
|
@@ -150,7 +150,7 @@ export class NpoDb extends Db {
|
|
|
150
150
|
|
|
151
151
|
async npo_referred_by(id: string): Promise<INpoReferredBy[]> {
|
|
152
152
|
const cmd = new QueryCommand({
|
|
153
|
-
TableName: NpoDb.
|
|
153
|
+
TableName: NpoDb.table,
|
|
154
154
|
IndexName: "gsi1",
|
|
155
155
|
KeyConditionExpression: "#pk = :pk",
|
|
156
156
|
ExpressionAttributeValues: {
|
|
@@ -164,7 +164,7 @@ export class NpoDb extends Db {
|
|
|
164
164
|
|
|
165
165
|
async npo_with_rid(id: string): Promise<INpoWithRid | undefined> {
|
|
166
166
|
const cmd = new QueryCommand({
|
|
167
|
-
TableName: NpoDb.
|
|
167
|
+
TableName: NpoDb.table,
|
|
168
168
|
IndexName: "gsi2",
|
|
169
169
|
KeyConditionExpression: "gsi2PK = :pk",
|
|
170
170
|
ExpressionAttributeValues: {
|
|
@@ -182,7 +182,7 @@ export class NpoDb extends Db {
|
|
|
182
182
|
country = "United States"
|
|
183
183
|
): Promise<INpoWithRegNum | undefined> {
|
|
184
184
|
const cmd = new QueryCommand({
|
|
185
|
-
TableName: NpoDb.
|
|
185
|
+
TableName: NpoDb.table,
|
|
186
186
|
IndexName: NpoDb.regnum_env_gsi,
|
|
187
187
|
Limit: 1,
|
|
188
188
|
KeyConditionExpression: "#rn = :rn AND #env = :env",
|
|
@@ -252,7 +252,7 @@ export class NpoDb extends Db {
|
|
|
252
252
|
featured: false,
|
|
253
253
|
});
|
|
254
254
|
const command = new PutCommand({
|
|
255
|
-
TableName: NpoDb.
|
|
255
|
+
TableName: NpoDb.table,
|
|
256
256
|
Item: item,
|
|
257
257
|
});
|
|
258
258
|
await this.client.send(command);
|
|
@@ -261,7 +261,7 @@ export class NpoDb extends Db {
|
|
|
261
261
|
|
|
262
262
|
async npo_med(npo: number, mid: string): Promise<IMedia | undefined> {
|
|
263
263
|
const cmd = new GetCommand({
|
|
264
|
-
TableName: NpoDb.
|
|
264
|
+
TableName: NpoDb.table,
|
|
265
265
|
Key: this.key_npo_med(mid, npo),
|
|
266
266
|
});
|
|
267
267
|
const { Item: i } = await this.client.send(cmd);
|
|
@@ -276,7 +276,7 @@ export class NpoDb extends Db {
|
|
|
276
276
|
);
|
|
277
277
|
|
|
278
278
|
const cmd = new UpdateCommand({
|
|
279
|
-
TableName: NpoDb.
|
|
279
|
+
TableName: NpoDb.table,
|
|
280
280
|
Key: this.key_npo_med(prev.id, npo),
|
|
281
281
|
UpdateExpression: "SET #url = :url, gsi1SK = :gsi1SK",
|
|
282
282
|
ExpressionAttributeNames: { "#url": "url" },
|
|
@@ -291,7 +291,7 @@ export class NpoDb extends Db {
|
|
|
291
291
|
|
|
292
292
|
async npo_med_delete(npo: number, mid: string) {
|
|
293
293
|
const cmd = new DeleteCommand({
|
|
294
|
-
TableName: NpoDb.
|
|
294
|
+
TableName: NpoDb.table,
|
|
295
295
|
Key: this.key_npo_med(mid, npo),
|
|
296
296
|
});
|
|
297
297
|
return this.client.send(cmd);
|
|
@@ -305,7 +305,7 @@ export class NpoDb extends Db {
|
|
|
305
305
|
|
|
306
306
|
if (typeof id === "string") {
|
|
307
307
|
const cmd = new QueryCommand({
|
|
308
|
-
TableName: NpoDb.
|
|
308
|
+
TableName: NpoDb.table,
|
|
309
309
|
IndexName: NpoDb.slug_env_gsi,
|
|
310
310
|
KeyConditionExpression: "#slug = :slug and #env = :env",
|
|
311
311
|
ExpressionAttributeValues: {
|
|
@@ -324,7 +324,7 @@ export class NpoDb extends Db {
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
const cmd = new GetCommand({
|
|
327
|
-
TableName: NpoDb.
|
|
327
|
+
TableName: NpoDb.table,
|
|
328
328
|
Key: this.key_npo(id),
|
|
329
329
|
ProjectionExpression: expression,
|
|
330
330
|
ExpressionAttributeNames: names,
|
|
@@ -366,7 +366,7 @@ export class NpoDb extends Db {
|
|
|
366
366
|
async npo_update(id: number, update: INpoUpdate) {
|
|
367
367
|
const upd8 = this.npo_update_comps(update);
|
|
368
368
|
const cmd = new UpdateCommand({
|
|
369
|
-
TableName: NpoDb.
|
|
369
|
+
TableName: NpoDb.table,
|
|
370
370
|
Key: this.key_npo(id),
|
|
371
371
|
...upd8,
|
|
372
372
|
ReturnValues: "ALL_NEW",
|
|
@@ -376,7 +376,7 @@ export class NpoDb extends Db {
|
|
|
376
376
|
|
|
377
377
|
async prog_milestones(id: string): Promise<IMilestone[]> {
|
|
378
378
|
const command = new QueryCommand({
|
|
379
|
-
TableName: NpoDb.
|
|
379
|
+
TableName: NpoDb.table,
|
|
380
380
|
KeyConditionExpression: `PK = :PK`,
|
|
381
381
|
ExpressionAttributeValues: {
|
|
382
382
|
":PK": this.key_prog_milestone("not-used", id).PK,
|
|
@@ -388,7 +388,7 @@ export class NpoDb extends Db {
|
|
|
388
388
|
}
|
|
389
389
|
async prog_milestone_delete(pid: string, mid: string) {
|
|
390
390
|
const cmd = new DeleteCommand({
|
|
391
|
-
TableName: NpoDb.
|
|
391
|
+
TableName: NpoDb.table,
|
|
392
392
|
Key: this.key_prog_milestone(mid, pid),
|
|
393
393
|
});
|
|
394
394
|
return this.client.send(cmd);
|
|
@@ -399,7 +399,7 @@ export class NpoDb extends Db {
|
|
|
399
399
|
): Promise<string> {
|
|
400
400
|
const item = this.prog_milestone_record(pid, content);
|
|
401
401
|
const cmd = new PutCommand({
|
|
402
|
-
TableName: NpoDb.
|
|
402
|
+
TableName: NpoDb.table,
|
|
403
403
|
Item: item,
|
|
404
404
|
});
|
|
405
405
|
return this.client.send(cmd).then(() => item.id);
|
|
@@ -416,7 +416,7 @@ export class NpoDb extends Db {
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
const cmd = new UpdateCommand({
|
|
419
|
-
TableName: NpoDb.
|
|
419
|
+
TableName: NpoDb.table,
|
|
420
420
|
Key: this.key_prog_milestone(mid, pid),
|
|
421
421
|
...upd8.collect(),
|
|
422
422
|
ReturnValues: "ALL_NEW",
|
|
@@ -426,7 +426,7 @@ export class NpoDb extends Db {
|
|
|
426
426
|
|
|
427
427
|
async npo_program(id: string, npo_id: number): Promise<IProgram | undefined> {
|
|
428
428
|
const cmd = new GetCommand({
|
|
429
|
-
TableName: NpoDb.
|
|
429
|
+
TableName: NpoDb.table,
|
|
430
430
|
Key: this.key_npo_program(id, npo_id),
|
|
431
431
|
});
|
|
432
432
|
const { Item: p } = await this.client.send(cmd);
|
|
@@ -441,7 +441,7 @@ export class NpoDb extends Db {
|
|
|
441
441
|
}
|
|
442
442
|
async npo_programs(id: number): Promise<IProgramDb[]> {
|
|
443
443
|
const cmd = new QueryCommand({
|
|
444
|
-
TableName: NpoDb.
|
|
444
|
+
TableName: NpoDb.table,
|
|
445
445
|
KeyConditionExpression: `PK = :PK and begins_with(SK, :SK)`,
|
|
446
446
|
ExpressionAttributeValues: {
|
|
447
447
|
":PK": this.key_npo_program("not-used", id).PK,
|
|
@@ -464,13 +464,13 @@ export class NpoDb extends Db {
|
|
|
464
464
|
totalDonations: 0,
|
|
465
465
|
});
|
|
466
466
|
txs.put({
|
|
467
|
-
TableName: NpoDb.
|
|
467
|
+
TableName: NpoDb.table,
|
|
468
468
|
Item: db_prog,
|
|
469
469
|
});
|
|
470
470
|
|
|
471
471
|
for (const m of milestones || []) {
|
|
472
472
|
txs.put({
|
|
473
|
-
TableName: NpoDb.
|
|
473
|
+
TableName: NpoDb.table,
|
|
474
474
|
Item: this.prog_milestone_record(pid, m),
|
|
475
475
|
});
|
|
476
476
|
}
|
|
@@ -487,13 +487,13 @@ export class NpoDb extends Db {
|
|
|
487
487
|
const milestones = await this.prog_milestones(prog);
|
|
488
488
|
const txs = new Txs();
|
|
489
489
|
txs.del({
|
|
490
|
-
TableName: NpoDb.
|
|
490
|
+
TableName: NpoDb.table,
|
|
491
491
|
Key: this.key_npo_program(prog, npo),
|
|
492
492
|
});
|
|
493
493
|
|
|
494
494
|
for (const m of milestones) {
|
|
495
495
|
txs.del({
|
|
496
|
-
TableName: NpoDb.
|
|
496
|
+
TableName: NpoDb.table,
|
|
497
497
|
Key: this.key_prog_milestone(m.id, prog),
|
|
498
498
|
});
|
|
499
499
|
}
|
|
@@ -511,7 +511,7 @@ export class NpoDb extends Db {
|
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
const cmd = new UpdateCommand({
|
|
514
|
-
TableName: NpoDb.
|
|
514
|
+
TableName: NpoDb.table,
|
|
515
515
|
Key: this.key_npo_program(prog, npo),
|
|
516
516
|
...upd8.collect(),
|
|
517
517
|
ReturnValues: "ALL_NEW",
|