@uql/core 3.4.2 → 3.4.3
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/CHANGELOG.md +6 -1
- package/README.md +38 -21
- package/dist/browser/uql-browser.min.js +2094 -947
- package/dist/browser/uql-browser.min.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [3.4.
|
|
6
|
+
## [3.4.3](https://github.com/rogerpadilla/uql/compare/@uql/core@3.4.2...@uql/core@3.4.3) (2025-12-31)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @uql/core
|
|
9
9
|
|
|
@@ -17,6 +17,11 @@ All notable changes to this project will be documented in this file. Please add
|
|
|
17
17
|
|
|
18
18
|
date format is [yyyy-mm-dd]
|
|
19
19
|
|
|
20
|
+
## [3.4.1]
|
|
21
|
+
### Improve documentation
|
|
22
|
+
|
|
23
|
+
- Update examples in docs
|
|
24
|
+
|
|
20
25
|
## [3.1.1](https://github.com/rogerpadilla/uql/compare/@uql/core@3.1.0...@uql/core@3.1.1) (2025-12-30)
|
|
21
26
|
### Bug Fixes
|
|
22
27
|
* adjust relative paths for README and CHANGELOG in copyfiles script ([741c2ee](https://github.com/rogerpadilla/uql/commit/741c2ee8839376ca89a860a53950ef6b6d234596))
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
```ts
|
|
15
|
-
const
|
|
15
|
+
const users = await querier.findMany(User, {
|
|
16
16
|
$select: { email: true, profile: { $select: { picture: true } } },
|
|
17
17
|
$where: { email: { $endsWith: '@domain.com' } },
|
|
18
18
|
$sort: { createdAt: 'desc' },
|
|
@@ -24,22 +24,22 @@ const companyUsers = await userRepository.findMany({
|
|
|
24
24
|
|
|
25
25
|
## Why UQL?
|
|
26
26
|
|
|
27
|
-
See [this article](https://medium.com/@rogerpadillac/in-search-of-the-perfect-orm-e01fcc9bce3d)
|
|
27
|
+
See [this article](https://medium.com/@rogerpadillac/in-search-of-the-perfect-orm-e01fcc9bce3d) on medium.com.
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
## Features
|
|
32
32
|
|
|
33
|
-
- **Type-safe and Context-aware queries**: Squeeze the power of `TypeScript` for auto-completion and validation of operators at any depth, [including relations and their fields](https://www.uql.app/
|
|
33
|
+
- **Type-safe and Context-aware queries**: Squeeze all the power of `TypeScript` for auto-completion and validation of operators at any depth, [including relations and their fields](https://www.uql.app/querying/relations).
|
|
34
34
|
- **Context-Object SQL Generation**: Uses a sophisticated `QueryContext` pattern to ensure perfectly indexed placeholders ($1, $2, etc.) and robust SQL fragment management, even in the most complex sub-queries.
|
|
35
35
|
- **Unified API across Databases**: Write once, run anywhere. Seamlessly switch between `PostgreSQL`, `MySQL`, `MariaDB`, `SQLite`, `LibSQL`, `Neon`, `Cloudflare D1`, and even `MongoDB`.
|
|
36
36
|
- **Serializable JSON Syntax**: Queries can be expressed as `100%` valid `JSON`, allowing them to be easily transported from frontend to backend.
|
|
37
37
|
- **Naming Strategies**: Effortlessly translate between TypeScript `CamelCase` and database `snake_case` (or any custom format) with a pluggable system.
|
|
38
|
-
- **Built-in Serialization**: A centralized task queue and `@Serialized()` decorator ensure database operations are thread-safe and race-condition
|
|
38
|
+
- **Built-in Serialization**: A centralized task queue and the `@Serialized()` decorator ensure that database operations are thread-safe and race-condition-free by default.
|
|
39
39
|
- **Database Migrations**: Integrated migration system for version-controlled schema management and auto-generation from entities.
|
|
40
40
|
- **High Performance**: Optimized "Sticky Connections" and human-readable, minimal SQL generation.
|
|
41
41
|
- **Modern Architecture**: Pure `ESM` support, designed for `Node.js`, `Bun`, `Deno`, and even mobile/browser environments.
|
|
42
|
-
- **Rich Feature Set**: [Soft-delete](https://uql.app/
|
|
42
|
+
- **Rich Feature Set**: [Soft-delete](https://www.uql.app/entities/soft-delete/), [virtual fields](https://uql.app/entities/virtual-fields), [repositories](https://uql.app/querying/repository), and automatic handling of `JSON`, `JSONB`, and `Vector` types.
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
@@ -67,7 +67,7 @@ See [this article](https://medium.com/@rogerpadillac/in-search-of-the-perfect-or
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
For example, for `Postgres
|
|
70
|
+
For example, for `Postgres`, install the `pg` driver:
|
|
71
71
|
|
|
72
72
|
```sh
|
|
73
73
|
npm install pg
|
|
@@ -83,7 +83,7 @@ bun add pg
|
|
|
83
83
|
"emitDecoratorMetadata": true
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
> **Note**: `"ES2022"`, `"ES2023"`, or `"ESNext"` will also work fine for `target`.
|
|
86
|
+
> **Note**: `"ES2022"`, `"ES2023"`, or `"ESNext"` will also work fine for the `target`.
|
|
87
87
|
|
|
88
88
|
---
|
|
89
89
|
|
|
@@ -172,9 +172,25 @@ export class PostTag {
|
|
|
172
172
|
|
|
173
173
|
|
|
174
174
|
|
|
175
|
-
## 3.
|
|
175
|
+
## 3. Set up a pool (of queriers)
|
|
176
176
|
|
|
177
|
-
A
|
|
177
|
+
A pool is an abstraction that manages connections (queriers) to your database. A querier is an abstraction that represents a connection to the database.
|
|
178
|
+
|
|
179
|
+
The pool can be set in any of the bootstrap files of your app (e.g., in `server.ts`).
|
|
180
|
+
|
|
181
|
+
### Available built-in QuerierPool classes per database
|
|
182
|
+
|
|
183
|
+
| Database | QuerierPool class
|
|
184
|
+
| :--- | :---
|
|
185
|
+
| `PostgreSQL` (incl. CockroachDB, YugabyteDB) | `@uql/core/postgres/PgQuerierPool`
|
|
186
|
+
| `MySQL` (incl. TiDB, Aurora) | `@uql/core/mysql/Mysql2QuerierPool`
|
|
187
|
+
| `MariaDB` | `@uql/core/maria/MariadbQuerierPool`
|
|
188
|
+
| `SQLite` | `@uql/core/sqlite/SqliteQuerierPool`
|
|
189
|
+
| `Cloudflare D1` | `@uql/core/d1/D1QuerierPool`
|
|
190
|
+
| `LibSQL` (Turso) | `@uql/core/libsql/LibsqlQuerierPool`
|
|
191
|
+
| `Neon` (Serverless Postgres) | `@uql/core/neon/NeonQuerierPool`
|
|
192
|
+
|
|
193
|
+
### Example of setting up a pool for PostgreSQL
|
|
178
194
|
|
|
179
195
|
```ts
|
|
180
196
|
// file: ./shared/orm.ts
|
|
@@ -190,12 +206,13 @@ export const pool = new PgQuerierPool(
|
|
|
190
206
|
min: 1,
|
|
191
207
|
max: 10,
|
|
192
208
|
},
|
|
193
|
-
//
|
|
209
|
+
// Extra options (optional).
|
|
194
210
|
{
|
|
195
|
-
//
|
|
211
|
+
// Pass any custom logger function here (optional).
|
|
196
212
|
logger: console.debug,
|
|
197
|
-
//
|
|
213
|
+
// Pass a naming strategy here (optional, by default no automatic names translation).
|
|
198
214
|
// This affects both queries and schema generation.
|
|
215
|
+
// E.g. `SnakeCaseNamingStrategy` automatically translate between TypeScript camelCase and database snake_case.
|
|
199
216
|
namingStrategy: new SnakeCaseNamingStrategy()
|
|
200
217
|
},
|
|
201
218
|
);
|
|
@@ -205,7 +222,7 @@ export const pool = new PgQuerierPool(
|
|
|
205
222
|
|
|
206
223
|
## 4. Manipulate the data
|
|
207
224
|
|
|
208
|
-
UQL provides multiple ways to interact with your data, from generic `Queriers` (that
|
|
225
|
+
UQL provides multiple ways to interact with your data, from generic `Queriers` (that work with any entity) to entity-specific `Repositories`.
|
|
209
226
|
|
|
210
227
|
```ts
|
|
211
228
|
import { User } from './shared/models/index.js';
|
|
@@ -319,7 +336,7 @@ const result = await pool.transaction(async (querier) => {
|
|
|
319
336
|
const profileId = await querier.insertOne(Profile, { userId: user.id, ... });
|
|
320
337
|
return { userId: user.id, profileId };
|
|
321
338
|
});
|
|
322
|
-
// Connection is automatically released after transaction
|
|
339
|
+
// Connection is automatically released after the transaction.
|
|
323
340
|
```
|
|
324
341
|
|
|
325
342
|
|
|
@@ -371,7 +388,7 @@ bunx uql-migrate status
|
|
|
371
388
|
|
|
372
389
|
### 3. Entity-First Synchronization (Development)
|
|
373
390
|
|
|
374
|
-
In development, you can use `autoSync` to automatically keep your database in sync with your entities
|
|
391
|
+
In development, you can use `autoSync` to automatically keep your database in sync with your entities, eliminating the need for manual migrations. It is **safe by default**, meaning it only adds missing tables and columns.
|
|
375
392
|
|
|
376
393
|
```ts
|
|
377
394
|
import { Migrator } from '@uql/core/migrate';
|
|
@@ -381,15 +398,15 @@ const migrator = new Migrator(pool);
|
|
|
381
398
|
await migrator.autoSync({ logging: true });
|
|
382
399
|
```
|
|
383
400
|
|
|
384
|
-
Check out the full [documentation](https://uql.app/
|
|
401
|
+
Check out the full [documentation](https://uql.app/migrations) for detailed CLI commands and advanced usage.
|
|
385
402
|
|
|
386
403
|
|
|
387
404
|
|
|
388
|
-
|
|
389
|
-
- [Complex Logical Operators](https://uql.app/
|
|
390
|
-
- [Relationship Mapping (1-1, 1-M, M-M)](https://uql.app/
|
|
391
|
-
- [Soft Deletes & Auditing](https://uql.app/
|
|
392
|
-
- [Database Migration & Syncing](https://uql.app/
|
|
405
|
+
Learn more about UQL at [uql.app](https://uql.app) for details on:
|
|
406
|
+
- [Complex Logical Operators](https://uql.app/querying-logical-operators)
|
|
407
|
+
- [Relationship Mapping (1-1, 1-M, M-M)](https://uql.app/querying-relations)
|
|
408
|
+
- [Soft Deletes & Auditing](https://uql.app/entities-soft-delete)
|
|
409
|
+
- [Database Migration & Syncing](https://uql.app/migrations)
|
|
393
410
|
|
|
394
411
|
---
|
|
395
412
|
|