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" width="250" height="208" />
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
- [![NPM Link](https://badgen.net/npm/v/sql-love?v=1.0.1)](https://npmjs.com/package/sql-love)
6
- [![Dependencies](https://badgen.net/static/dependencies/0/green?v=1.0.1)](https://www.npmjs.com/package/sql-love?activeTab=dependencies)
7
- [![Build Status](https://github.com/kensnyder/sql-love/actions/workflows/node.js.yml/badge.svg?v=1.0.1)](https://github.com/kensnyder/sql-love/actions)
8
- [![Code Coverage](https://codecov.io/gh/kensnyder/sql-love/branch/main/graph/badge.svg?v=1.0.1)](https://codecov.io/gh/kensnyder/sql-love)
9
- [![ISC License](https://badgen.net/static/license/ISC/green?v=1.0.1)](https://opensource.org/licenses/ISC)
5
+ [![NPM Link](https://badgen.net/npm/v/sql-love?v=1.0.2)](https://npmjs.com/package/sql-love)
6
+ [![Dependencies](https://badgen.net/static/dependencies/0/green?v=1.0.2)](https://www.npmjs.com/package/sql-love?activeTab=dependencies)
7
+ [![Build Status](https://github.com/kensnyder/sql-love/actions/workflows/node.js.yml/badge.svg?v=1.0.2)](https://github.com/kensnyder/sql-love/actions)
8
+ [![Code Coverage](https://codecov.io/gh/kensnyder/sql-love/branch/main/graph/badge.svg?v=1.0.2)](https://codecov.io/gh/kensnyder/sql-love)
9
+ [![ISC License](https://badgen.net/static/license/ISC/green?v=1.0.2)](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<Array<Record<string, any>>>;
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: Record<string, any>[];
29
- total: any;
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);
@@ -1,4 +1,4 @@
1
- type SafeValue<T> = T extends BigInt ? number | string : T extends Date ? string : T;
1
+ type SafeValue<T> = T extends BigInt ? number | string : T;
2
2
  type SafeRecord<T> = Record<string, SafeValue<T>>;
3
3
  type SafeRecords<T> = Array<SafeRecord<T>>;
4
4
  /**
@@ -11,9 +11,6 @@ export function toSafeJsonValue(value) {
11
11
  // @ts-expect-error
12
12
  return value == asNumber ? asNumber : value.toString();
13
13
  }
14
- if (value instanceof Date) {
15
- return value.toISOString();
16
- }
17
14
  return value;
18
15
  }
19
16
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sql-love",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Build SQL queries with JavaScript",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",