sql-love 1.0.1 → 1.0.2
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/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<img alt="SQL Love Logo" src="https://github.com/kensnyder/sql-love/raw/main/assets/sql-love-logo.png?v=1.0.
|
|
1
|
+
<img alt="SQL Love Logo" src="https://github.com/kensnyder/sql-love/raw/main/assets/sql-love-logo.png?v=1.0.2" width="250" height="208" />
|
|
2
2
|
|
|
3
3
|
# sql-love
|
|
4
4
|
|
|
5
|
-
[](https://npmjs.com/package/sql-love)
|
|
6
|
+
[](https://www.npmjs.com/package/sql-love?activeTab=dependencies)
|
|
7
|
+
[](https://github.com/kensnyder/sql-love/actions)
|
|
8
|
+
[](https://codecov.io/gh/kensnyder/sql-love)
|
|
9
|
+
[](https://opensource.org/licenses/ISC)
|
|
10
10
|
|
|
11
11
|
Classes for parsing and building SQL select queries in Node
|
|
12
12
|
|
|
@@ -10,9 +10,9 @@ interface PrismaClient {
|
|
|
10
10
|
* @param options
|
|
11
11
|
* @param options.engine The engine style to use ("mssql" | "mysql" | "oracle" | "pg")
|
|
12
12
|
*/
|
|
13
|
-
export declare function runPrisma(prisma: PrismaClient, query: SelectBuilder, { engine }?: {
|
|
13
|
+
export declare function runPrisma<T extends Array<Record<string, any>> = Array<Record<string, any>>>(prisma: PrismaClient, query: SelectBuilder, { engine }?: {
|
|
14
14
|
engine?: EngineStyle;
|
|
15
|
-
}): Promise<
|
|
15
|
+
}): Promise<T>;
|
|
16
16
|
/**
|
|
17
17
|
* Run the given query with prisma and return the results, count, and pagination
|
|
18
18
|
* @param prisma The prisma client instance
|
|
@@ -21,12 +21,12 @@ export declare function runPrisma(prisma: PrismaClient, query: SelectBuilder, {
|
|
|
21
21
|
* @param options.engine The engine style to use ("mssql" | "mysql" | "oracle" | "pg")
|
|
22
22
|
* @param options.countExpr The SQL expression to use for the count (default "*")
|
|
23
23
|
*/
|
|
24
|
-
export declare function runPrismaWithCount(prisma: PrismaClient, query: SelectBuilder, { engine, countExpr, }?: {
|
|
24
|
+
export declare function runPrismaWithCount<T extends Array<Record<string, any>> = Array<Record<string, any>>>(prisma: PrismaClient, query: SelectBuilder, { engine, countExpr, }?: {
|
|
25
25
|
engine?: EngineStyle;
|
|
26
26
|
countExpr?: string;
|
|
27
27
|
}): Promise<{
|
|
28
|
-
records:
|
|
29
|
-
total:
|
|
28
|
+
records: T;
|
|
29
|
+
total: number;
|
|
30
30
|
pagination: {
|
|
31
31
|
page: number;
|
|
32
32
|
prevPage: number;
|
|
@@ -21,7 +21,7 @@ export async function runPrisma(prisma, query, { engine = undefined } = {}) {
|
|
|
21
21
|
*/
|
|
22
22
|
export async function runPrismaWithCount(prisma, query, { engine = undefined, countExpr = '*', } = {}) {
|
|
23
23
|
const { sql, bindings } = query.compile({ engine });
|
|
24
|
-
const records = await prisma.$queryRawUnsafe(sql, ...bindings);
|
|
24
|
+
const records = (await prisma.$queryRawUnsafe(sql, ...bindings));
|
|
25
25
|
if (records.length > 0) {
|
|
26
26
|
const { sql, bindings } = query.compileCount({ engine, countExpr });
|
|
27
27
|
const result = await prisma.$queryRawUnsafe(sql, ...bindings);
|