Skip to content

Commit 4af8455

Browse files
authored
Merge pull request #38 from nalanj/remove-query-fns
Remove queryfn
2 parents 10a4bb6 + 55cef1f commit 4af8455

5 files changed

Lines changed: 0 additions & 159 deletions

File tree

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,6 @@ transaction function, `tx`, includes a property `rollback()` to roll back the
193193
transaction at any point. If any exception is thrown inside of the transaction
194194
it also causes the transaction to roll back.
195195

196-
### Define query functions
197-
198-
`pg-ist` includes the ability to efficiently define query functions. `queryFn`,
199-
`oneFn`, and `onlyOneFn` are all available.
200-
201-
```ts
202-
import { type User, db } from "./db.js";
203-
204-
db.queryFn<User, { id: string }>`SELECT * FROM users WHERE id = ${"id"}`;
205-
```
206-
207-
This defines a function that accepts a properties object with one property, `id`, and returns an iterable set of `User` objects.
208-
209196
### Cursors
210197

211198
`pg-ist` supports cursors. They're ideal for situations where you need to iterate over large sets of rows.

db.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import pg from "pg";
22
import Cursor from "pg-cursor";
33
import { type QueryResult, query, queryOne, queryOnlyOne } from "./query.js";
44
import { cursorRowConverter } from "./query.js";
5-
import { oneFn, onlyOneFn, queryFn } from "./queryFn.js";
65
import { sql } from "./sql.js";
76
import { tx } from "./tx.js";
87

@@ -95,30 +94,6 @@ export class DB implements Queryable {
9594
}
9695
}
9796

98-
queryFn<T extends object, P = Record<string, unknown>>(
99-
strings: TemplateStringsArray,
100-
...argsIn: (keyof P)[]
101-
) {
102-
const fn = queryFn(strings, ...argsIn);
103-
return (props: P, tx?: Queryable) => fn(props, tx || this);
104-
}
105-
106-
oneFn<T extends object, P = Record<string, unknown>>(
107-
strings: TemplateStringsArray,
108-
...argsIn: (keyof P)[]
109-
) {
110-
const fn = oneFn(strings, ...argsIn);
111-
return (props: P, tx?: Queryable) => fn(props, tx || this);
112-
}
113-
114-
onlyOneFn<T extends object, P = Record<string, unknown>>(
115-
strings: TemplateStringsArray,
116-
...argsIn: (keyof P)[]
117-
) {
118-
const fn = onlyOneFn(strings, ...argsIn);
119-
return (props: P, tx?: Queryable) => fn(props, tx || this);
120-
}
121-
12297
cursor(rowCount = 100) {
12398
const pool = this.pool;
12499

examples/query-fn.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

queryFn.test.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

queryFn.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)