@uql/core 3.4.2 → 3.4.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/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.2](https://github.com/rogerpadilla/uql/compare/@uql/core@3.4.1...@uql/core@3.4.2) (2025-12-31)
6
+ ## [3.4.4](https://github.com/rogerpadilla/uql/compare/@uql/core@3.4.3...@uql/core@3.4.4) (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 companyUsers = await userRepository.findMany({
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) in medium.com.
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/docs/querying-relations).
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 free by default.
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/docs/entities-soft-delete), [virtual fields](https://uql.app/docs/entities-virtual-fields), [repositories](https://uql.app/docs/querying-repository), and automatic handling of `JSON`, `JSONB`, and `Vector` types.
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
 
@@ -65,9 +65,8 @@ See [this article](https://medium.com/@rogerpadillac/in-search-of-the-perfect-or
65
65
  | `LibSQL` (Turso) | `@libsql/client`
66
66
  | `Neon` (Serverless Postgres) | `@neondatabase/serverless`
67
67
 
68
-  
69
68
 
70
- For example, for `Postgres` install the `pg` driver:
69
+ For example, for `Postgres`, install the `pg` driver:
71
70
 
72
71
  ```sh
73
72
  npm install pg
@@ -83,7 +82,7 @@ bun add pg
83
82
  "emitDecoratorMetadata": true
84
83
  ```
85
84
 
86
- > **Note**: `"ES2022"`, `"ES2023"`, or `"ESNext"` will also work fine for `target`.
85
+ > **Note**: `"ES2022"`, `"ES2023"`, or `"ESNext"` will also work fine for the `target`.
87
86
 
88
87
  ---
89
88
 
@@ -172,9 +171,25 @@ export class PostTag {
172
171
 
173
172
   
174
173
 
175
- ## 3. Setup a querier-pool
174
+ ## 3. Set up a pool (of queriers)
175
+
176
+ A pool is an abstraction that manages connections (queriers) to your database. A querier is an abstraction that represents a connection to the database.
177
+
178
+ The pool can be set in any of the bootstrap files of your app (e.g., in `server.ts`).
179
+
180
+ ### Available built-in QuerierPool classes per database
181
+
182
+ | Database | QuerierPool class
183
+ | :--- | :---
184
+ | `PostgreSQL` (incl. CockroachDB, YugabyteDB) | `@uql/core/postgres/PgQuerierPool`
185
+ | `MySQL` (incl. TiDB, Aurora) | `@uql/core/mysql/Mysql2QuerierPool`
186
+ | `MariaDB` | `@uql/core/maria/MariadbQuerierPool`
187
+ | `SQLite` | `@uql/core/sqlite/SqliteQuerierPool`
188
+ | `Cloudflare D1` | `@uql/core/d1/D1QuerierPool`
189
+ | `LibSQL` (Turso) | `@uql/core/libsql/LibsqlQuerierPool`
190
+ | `Neon` (Serverless Postgres) | `@uql/core/neon/NeonQuerierPool`
176
191
 
177
- A querier-pool can be set in any of the bootstrap files of your app (e.g. in the `server.ts`).
192
+ ### Example of setting up a pool for PostgreSQL
178
193
 
179
194
  ```ts
180
195
  // file: ./shared/orm.ts
@@ -190,12 +205,13 @@ export const pool = new PgQuerierPool(
190
205
  min: 1,
191
206
  max: 10,
192
207
  },
193
- // Optional extra options.
208
+ // Extra options (optional).
194
209
  {
195
- // Optional, any custom logger function can be passed here (optional).
210
+ // Pass any custom logger function here (optional).
196
211
  logger: console.debug,
197
- // Automatically translate between TypeScript camelCase and database snake_case.
212
+ // Pass a naming strategy here (optional, by default no automatic names translation).
198
213
  // This affects both queries and schema generation.
214
+ // E.g. `SnakeCaseNamingStrategy` automatically translate between TypeScript camelCase and database snake_case.
199
215
  namingStrategy: new SnakeCaseNamingStrategy()
200
216
  },
201
217
  );
@@ -205,7 +221,7 @@ export const pool = new PgQuerierPool(
205
221
 
206
222
  ## 4. Manipulate the data
207
223
 
208
- UQL provides multiple ways to interact with your data, from generic `Queriers` (that works with any entity) to entity-specific `Repositories`.
224
+ UQL provides multiple ways to interact with your data, from generic `Queriers` (that work with any entity) to entity-specific `Repositories`.
209
225
 
210
226
  ```ts
211
227
  import { User } from './shared/models/index.js';
@@ -227,8 +243,9 @@ try {
227
243
  email: { $iincludes: '@example.com' }, // Case-insensitive search
228
244
  status: 'active'
229
245
  },
230
- $sort: { createdAt: -1 },
231
- $limit: 50
246
+ $sort: { createdAt: 'desc' },
247
+ $skip: 10
248
+ $limit: 10,
232
249
  });
233
250
  } finally {
234
251
  // Always release the querier to the pool
@@ -261,8 +278,7 @@ try {
261
278
  $select: ['title', 'createdAt'],
262
279
  // Filter the related collection directly
263
280
  $where: { title: { $iincludes: 'typescript' } },
264
- $sort: { createdAt: -1 },
265
- $limit: 5
281
+ $sort: { createdAt: 'desc' },
266
282
  }
267
283
  },
268
284
  $where: {
@@ -319,14 +335,14 @@ const result = await pool.transaction(async (querier) => {
319
335
  const profileId = await querier.insertOne(Profile, { userId: user.id, ... });
320
336
  return { userId: user.id, profileId };
321
337
  });
322
- // Connection is automatically released after transaction
338
+ // Connection is automatically released after a transaction.
323
339
  ```
324
340
 
325
341
   
326
342
 
327
343
  ## 5. Migrations & Synchronization
328
344
 
329
- UQL includes a robust migration system and an "Entity-First" synchronization engine built directly into the core.
345
+ UQL includes a robust *migration system* and an *Entity-First auto-synchronization* engine built directly into the core.
330
346
 
331
347
  ### 1. Create Configuration
332
348
 
@@ -369,9 +385,9 @@ npx uql-migrate status
369
385
  bunx uql-migrate status
370
386
  ```
371
387
 
372
- ### 3. Entity-First Synchronization (Development)
388
+ ### 3. Entity-First Synchronization (recommended for development)
373
389
 
374
- In development, you can use `autoSync` to automatically keep your database in sync with your entities without manual migrations. It is **safe by default**, meaning it only adds missing tables and columns.
390
+ We recommend using `autoSync` (in development) 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
391
 
376
392
  ```ts
377
393
  import { Migrator } from '@uql/core/migrate';
@@ -381,15 +397,15 @@ const migrator = new Migrator(pool);
381
397
  await migrator.autoSync({ logging: true });
382
398
  ```
383
399
 
384
- Check out the full [documentation](https://uql.app/docs/migrations) for detailed CLI commands and advanced usage.
400
+ Check out the full [documentation](https://uql.app/migrations) for detailed CLI commands and advanced usage.
385
401
 
386
402
   
387
403
 
388
- Check out the full documentation at [uql.app](https://uql.app) for details on:
389
- - [Complex Logical Operators](https://uql.app/docs/querying-logical-operators)
390
- - [Relationship Mapping (1-1, 1-M, M-M)](https://uql.app/docs/querying-relations)
391
- - [Soft Deletes & Auditing](https://uql.app/docs/entities-soft-delete)
392
- - [Database Migration & Syncing](https://uql.app/docs/migrations)
404
+ Learn more about UQL at [uql.app](https://uql.app) for details on:
405
+ - [Complex Logical Operators](https://uql.app/querying/logical-operators)
406
+ - [Relationship Mapping (1-1, 1-M, M-M)](https://uql.app/querying/relations)
407
+ - [Soft Deletes & Auditing](https://uql.app/entities/soft-delete)
408
+ - [Database Migration & Syncing](https://uql.app/migrations)
393
409
 
394
410
  ---
395
411
 
@@ -403,7 +419,6 @@ For those who want to see the "engine under the hood," check out these resources
403
419
  - [Abstract SQL Spec](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/dialect/abstractSqlDialect-spec.ts): The base test suite shared by all dialects.
404
420
  - [PostgreSQL Spec](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/postgres/postgresDialect.spec.ts) | [MySQL Spec](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/mysql/mysqlDialect.spec.ts) | [SQLite Spec](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/sqlite/sqliteDialect.spec.ts).
405
421
  - [Querier Integration Tests](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/querier/abstractSqlQuerier-spec.ts): Testing the interaction between SQL generation and connection management.
406
- - [MongoDB Migration Tests](https://github.com/rogerpadilla/uql/blob/main/packages/core/src/migrate/migrator-mongo.it.ts): Integration tests ensuring correct collection and index synchronization for MongoDB.
407
422
 
408
423
  ---
409
424