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/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<img alt="SQL Love Logo" src="https://github.com/kensnyder/sql-love/raw/main/assets/sql-love-logo.png?v=1.1.
|
|
1
|
+
<img alt="SQL Love Logo" src="https://github.com/kensnyder/sql-love/raw/main/assets/sql-love-logo.png?v=1.1.4" width="250" height="208" />
|
|
2
2
|
|
|
3
3
|
# sql-love
|
|
4
4
|
|
|
5
|
-
[](https://codecov.io/gh/kensnyder/sql-love)
|
|
5
|
+
[](https://github.com/search?q=repo:kensnyder/sql-love++language:TypeScript&type=code)
|
|
6
|
+
[](https://codecov.io/gh/kensnyder/sql-love)
|
|
8
7
|

|
|
9
8
|

|
|
10
|
-
|
|
9
|
+

|
|
10
|
+
[](https://opensource.org/licenses/ISC)
|
|
11
11
|
|
|
12
12
|
Classes for parsing and building SQL select queries in Node/Bun/Deno.
|
|
13
13
|
|
|
@@ -189,7 +189,7 @@ Use the following methods to build queries. And see
|
|
|
189
189
|
- `query.having(columnValueRecord)` - Add multiple conditions
|
|
190
190
|
- `query.orHaving(expressions)` - Multiple `having()`s joined by OR
|
|
191
191
|
- `query.orderBy(column, direction)` - Add ORDER BY clause
|
|
192
|
-
- `query.sortField(
|
|
192
|
+
- `query.sortField(field, mapNames, modifier)` - Add ORDER BY clause for an allowed field in mapNames
|
|
193
193
|
- `query.limit(num)` - Limit by the given number
|
|
194
194
|
- `query.offset(num)` - Specify an offset
|
|
195
195
|
- `query.page(num)` - Automatically calculate offset based on limit and page
|
|
@@ -316,8 +316,11 @@ query.orderBy('modified_at DESC NULLS LAST'); // ORDER BY modified_at DESC NULLS
|
|
|
316
316
|
query.orderBy('modified_at USING >'); // ORDER BY modified_at USING >
|
|
317
317
|
|
|
318
318
|
// Sorting with support for hyphens and mapping
|
|
319
|
-
|
|
319
|
+
// Only fields present in mapNames are allowed, so field names may safely
|
|
320
|
+
// come from user input (e.g. a "?sort=-created" query string param).
|
|
321
|
+
// Unknown fields emit a console.warn and add no ORDER BY clause.
|
|
320
322
|
query.sortField('-created', { created: 'created_at' }); // ORDER BY created_at DESC
|
|
323
|
+
query.sortField('-foo', { created: 'created_at' }); // console.warn; no ORDER BY added
|
|
321
324
|
query.sortField(
|
|
322
325
|
'-created_at',
|
|
323
326
|
{
|