You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
redundent console log removed from legacy file,
switch case removed to check execution,
handleExecution object functions created,
alias identifiers optimized,
multi-query support patched to rawQuery method using keyword,
Fallback handler IfNull method patched as property to all aggregate methods,
prepared statement now defaults to '' instead of null,
constants now also contains null as key,
regular null value is now handled by prepWhere function,
placeholder helper optimized,
type definitions patched,
code cleanup,
code optimization
**UnSQL** is a lightweight, open-source JavaScript library that facilitates class based, schemaless interactions with the structured databases viz. `MySQL`, `PostgreSQL` and `SQLite` through dynamic query generation. It is compatible with javascript runtime environments like NodeJS and NextJS.
8
+
**UnSQL** is a lightweight, open-source JavaScript library that facilitates class based, schemaless interactions with the structured databases viz. `MySQL`, `PostgreSQL` and `SQLite` through dynamic query generation. It is the only library that supports single codebase across all dialects. It is compatible with javascript runtime environments like NodeJS and NextJS.
9
9
10
10
## Table of Contents
11
11
1.[Overview](#1-overview)
@@ -34,7 +34,7 @@
34
34
35
35
## 1. Overview
36
36
37
-
**UnSQL** simplifies working with structured databases by dynamically generating SQLs under the hood. It provides developer friendly interface while eliminating the complexities of SQL. UnSQL also utilizes placeholders and prepared statements to prevent SQL-injections.
37
+
**UnSQL** simplifies working with structured databases by dynamically generating SQLs under the hood. It provides developer friendly interface while eliminating the complexities of SQL. UnSQL also utilizes placeholders and parameterized SQL statements to prevent SQL-injections.
38
38
39
39
### 1.1 Breaking Changes
40
40
@@ -88,9 +88,12 @@ UnSQL can work with three different `dialect` of SQL (`'mysql'`, `'postgresql'`
88
88
importmysql2from'mysql2/promise'
89
89
90
90
exportconstpool=createPool({
91
-
...,
91
+
host:'localhost', // or link to remote database
92
+
database:'test_db',
93
+
user:'your_username',
94
+
password:'your_password',
92
95
namedPlaceholders:true, // (optional) required if using rawQuery with named placeholders
93
-
multipleStatements:true// (optional) required if using Encryption/Decryption features
96
+
multipleStatements:true// (optional) required if using multiple statements in rawQuery
94
97
})
95
98
```
96
99
@@ -101,7 +104,12 @@ export const pool = createPool({
101
104
```javascript
102
105
import { Pool } from'pg'
103
106
104
-
exportconstpool=newPool({...})
107
+
exportconstpool=newPool({
108
+
host:'localhost',
109
+
database:'test_db',
110
+
user:'your_username',
111
+
password:'your_password'
112
+
})
105
113
```
106
114
107
115
-**SQLite** (`dialect: 'sqlite'`)
@@ -460,6 +468,8 @@ Each of these properties is explained below:
460
468
461
469
`rawQuery` method is the most powerful method among all, unlike other methods that are limited to the base mapping, this method is not tied to any particular table, but utilizes the connection pool to execute queries on that database itself. It is capable of executing any and all types of queries including **DDL, DML etc** (In `sqlite`, set `methodType: 'exec'`). It also supports execution of multiple SQL statements in one query. When multiple `SELECT` statements are executed (not supported by `sqlite`), `result` contains nested array one for each `SELECT` statement.
462
470
471
+
In `mysql`, use `multiQuery: true` to enable execution of multiple SQL statements in single query
472
+
463
473
For `sqlite`, UnSQL supports various types ofmethods (as mentioned below) that can be set manually, each method has specific capabilities:
464
474
465
475
| Method Type | Description |
@@ -502,7 +512,7 @@ const response = await User.rawQuery({ // here user model is used just to utiliz
0 commit comments