@better-giving/fundraiser 3.0.10 → 3.0.12

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 CHANGED
@@ -34,6 +34,7 @@ export declare class FundDb extends Db {
34
34
  fund_put_txi(data: IFund): TxType["Put"];
35
35
  /**@param id - slug or uuid */
36
36
  fund(id: string): Promise<IFund | undefined>;
37
- fund_edit(id: string, { target, slug, ...update }: IFundUpdate): Promise<Record<string, any>>;
37
+ funds_get(ids: string[]): Promise<IFund[]>;
38
+ fund_update(id: string, { target, slug, ...update }: IFundUpdate): Promise<Record<string, any>>;
38
39
  fund_close(fund: string): Promise<import("@aws-sdk/lib-dynamodb").UpdateCommandOutput>;
39
40
  }
package/dist/db.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { QueryCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
1
+ import { BatchGetCommand, QueryCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
2
2
  import { Db, UpdateBuilder } from "@better-giving/db";
3
3
  import { UUID_REGEX } from "valibot";
4
4
  export class FundDb extends Db {
@@ -43,7 +43,17 @@ export class FundDb extends Db {
43
43
  const { Items: i = [] } = await this.client.send(new QueryCommand(q));
44
44
  return i[0] && this.sans_keys(i[0]);
45
45
  }
46
- async fund_edit(id, { target, slug, ...update }) {
46
+ async funds_get(ids) {
47
+ const cmd = new BatchGetCommand({
48
+ RequestItems: {
49
+ [FundDb.table]: { Keys: ids.map((id) => this.key_fund(id)) },
50
+ },
51
+ });
52
+ const { Responses } = await this.client.send(cmd);
53
+ const x = Responses?.[FundDb.table] ?? [];
54
+ return x.map((i) => this.sans_keys(i));
55
+ }
56
+ async fund_update(id, { target, slug, ...update }) {
47
57
  const updates = new UpdateBuilder();
48
58
  if (slug)
49
59
  updates.set("slug", slug);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/fundraiser",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "peerDependencies": {
5
5
  "valibot": "0.42.0",
6
6
  "@better-giving/schemas": "2.0.0",
package/src/db.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ BatchGetCommand,
2
3
  QueryCommand,
3
4
  type QueryCommandInput,
4
5
  UpdateCommand,
@@ -51,7 +52,18 @@ export class FundDb extends Db {
51
52
  return i[0] && this.sans_keys(i[0]);
52
53
  }
53
54
 
54
- async fund_edit(id: string, { target, slug, ...update }: IFundUpdate) {
55
+ async funds_get(ids: string[]): Promise<IFund[]> {
56
+ const cmd = new BatchGetCommand({
57
+ RequestItems: {
58
+ [FundDb.table]: { Keys: ids.map((id) => this.key_fund(id)) },
59
+ },
60
+ });
61
+ const { Responses } = await this.client.send(cmd);
62
+ const x = Responses?.[FundDb.table] ?? [];
63
+ return x.map((i) => this.sans_keys(i));
64
+ }
65
+
66
+ async fund_update(id: string, { target, slug, ...update }: IFundUpdate) {
55
67
  const updates = new UpdateBuilder();
56
68
 
57
69
  if (slug) updates.set("slug", slug);