Skip to content

Commit 8387069

Browse files
committed
WiP
1 parent 8b5d3af commit 8387069

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

packages/orb-sync-lib/src/database/postgres.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,8 @@ export class PostgresClient {
7272
;`;
7373
};
7474

75-
async select<T>(sqlQuery: string, params?: Record<string, unknown>): Promise<T[]> {
76-
const prepared = sql(sqlQuery, { useNullForMissing: true })(params || {});
77-
const result = await this.pool.query(prepared.text, prepared.values);
78-
79-
return result.rows;
75+
async query(text: string, params?: string[]): Promise<QueryResult> {
76+
return this.pool.query(text, params);
8077
}
8178

8279
/**

packages/orb-sync-lib/src/sync/invoices.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ export async function syncInvoices(postgresClient: PostgresClient, invoices: Inv
1010
const invoiceIds = invoices.map((invoice) => invoice.id);
1111

1212
// Fetch existing invoices from the database
13-
const existingInvoices = (await postgresClient.select(
14-
`SELECT id, last_synced_at FROM ${TABLE} WHERE id IN (${invoiceIds.join(',')})`
15-
)) as { id: string; last_synced_at: string }[];
13+
const existingInvoices = (
14+
await postgresClient.query(
15+
`SELECT id, last_synced_at FROM ${TABLE} WHERE id IN (${invoiceIds.join(',')})`
16+
)
17+
).rows as { id: string; last_synced_at: string }[];
1618

1719
// Filter out invoices that have been synced since the sync timestamp
1820
const invoicesToUpsert = invoices.filter((invoice) => {

0 commit comments

Comments
 (0)