sql-love 1.1.1 → 1.1.4
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 +10 -7
- package/dist/index.cjs +585 -112
- package/dist/index.d.ts +16 -13
- package/dist/index.mjs +552 -88
- package/package.json +10 -8
- package/dist/.gitkeep +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -69,17 +69,17 @@ export declare class SelectBuilder {
|
|
|
69
69
|
* The LIMIT to use
|
|
70
70
|
* @private
|
|
71
71
|
*/
|
|
72
|
-
_limit
|
|
72
|
+
_limit?: number;
|
|
73
73
|
/**
|
|
74
74
|
* The OFFSET to use
|
|
75
75
|
* @private
|
|
76
76
|
*/
|
|
77
|
-
_offset
|
|
77
|
+
_offset?: number;
|
|
78
78
|
/**
|
|
79
79
|
* The page used to construct an OFFSET based on the LIMIT
|
|
80
80
|
* @private
|
|
81
81
|
*/
|
|
82
|
-
_page
|
|
82
|
+
_page?: number;
|
|
83
83
|
/**
|
|
84
84
|
* Select constructor
|
|
85
85
|
* @param [sql] A base SQL query to parse
|
|
@@ -359,13 +359,16 @@ export declare class SelectBuilder {
|
|
|
359
359
|
*/
|
|
360
360
|
orderBy(column: string, direction?: "ASC" | "DESC"): this;
|
|
361
361
|
/**
|
|
362
|
-
* Sort by the given
|
|
363
|
-
*
|
|
364
|
-
*
|
|
362
|
+
* Sort by the given field, with a map of allowed fields to column expressions.
|
|
363
|
+
* Only field names present in mapNames are allowed; anything else emits a
|
|
364
|
+
* console.warn and adds no ORDER BY clause. This prevents SQL injection when
|
|
365
|
+
* fieldName comes from user input.
|
|
366
|
+
* @param fieldName The field name such as 'created' or '-created' for descending
|
|
367
|
+
* @param mapNames Allowed field names mapped to column expressions
|
|
365
368
|
* @param [modifier] Additional clause to append such as 'NULLS LAST' or 'COLLATE "en_US"'
|
|
366
369
|
* @example
|
|
367
|
-
* query.sortField('-modified_at'); // ORDER BY modified_at DESC
|
|
368
370
|
* query.sortField('-created', {'created': 'created_at'}); // ORDER BY created_at DESC
|
|
371
|
+
* query.sortField('-foo', {'created': 'created_at'}); // console.warn; no ORDER BY added
|
|
369
372
|
* query.sortField('-created', {
|
|
370
373
|
* 'created': 'created_at NULLS LAST',
|
|
371
374
|
* '-created': 'created_at DESC NULLS LAST'
|
|
@@ -374,7 +377,7 @@ export declare class SelectBuilder {
|
|
|
374
377
|
* 'name': 'name COLLATE "jp_JP"'
|
|
375
378
|
* }); // ORDER BY name COLLATE "jp_JP" DESC
|
|
376
379
|
*/
|
|
377
|
-
sortField(fieldName:
|
|
380
|
+
sortField(fieldName: any, mapNames?: Record<string, string>, modifier?: string): this;
|
|
378
381
|
/**
|
|
379
382
|
* Check to see if the given string is 0 or all digits not starting with 0
|
|
380
383
|
* @param string The input string
|
|
@@ -428,7 +431,7 @@ export declare class Parser {
|
|
|
428
431
|
*/
|
|
429
432
|
_extractSubQueries(sql: string): {
|
|
430
433
|
sql: string;
|
|
431
|
-
subQueries:
|
|
434
|
+
subQueries: Record<string, string>;
|
|
432
435
|
};
|
|
433
436
|
/**
|
|
434
437
|
* Inject column subQueries back into this object
|
|
@@ -704,10 +707,10 @@ export declare function runPrismaWithCount<T extends Array<Record<string, any>>
|
|
|
704
707
|
records: T;
|
|
705
708
|
total: number;
|
|
706
709
|
pagination: {
|
|
707
|
-
page: number;
|
|
708
|
-
prevPage: number;
|
|
709
|
-
nextPage: number;
|
|
710
|
-
perPage: number;
|
|
710
|
+
page: number | null;
|
|
711
|
+
prevPage: number | null;
|
|
712
|
+
nextPage: number | null;
|
|
713
|
+
perPage: number | null;
|
|
711
714
|
numPages: number;
|
|
712
715
|
total: number;
|
|
713
716
|
isFirst: boolean;
|