@uql/core 3.3.0 → 3.4.2
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 +1 -1
- package/README.md +22 -26
- package/dist/browser/uql-browser.min.js +947 -2094
- package/dist/browser/uql-browser.min.js.map +1 -1
- package/dist/d1/d1Querier.d.ts +49 -0
- package/dist/d1/d1Querier.d.ts.map +1 -0
- package/dist/d1/d1Querier.js +40 -0
- package/dist/d1/d1Querier.js.map +1 -0
- package/dist/d1/d1QuerierPool.d.ts +10 -0
- package/dist/d1/d1QuerierPool.d.ts.map +1 -0
- package/dist/d1/d1QuerierPool.js +16 -0
- package/dist/d1/d1QuerierPool.js.map +1 -0
- package/dist/d1/index.d.ts +3 -0
- package/dist/d1/index.d.ts.map +1 -0
- package/dist/d1/index.js +3 -0
- package/dist/d1/index.js.map +1 -0
- package/dist/libsql/index.d.ts +3 -0
- package/dist/libsql/index.d.ts.map +1 -0
- package/dist/libsql/index.js +3 -0
- package/dist/libsql/index.js.map +1 -0
- package/dist/libsql/libsqlQuerier.d.ts +21 -0
- package/dist/libsql/libsqlQuerier.d.ts.map +1 -0
- package/dist/libsql/libsqlQuerier.js +81 -0
- package/dist/libsql/libsqlQuerier.js.map +1 -0
- package/dist/libsql/libsqlQuerierPool.d.ts +12 -0
- package/dist/libsql/libsqlQuerierPool.d.ts.map +1 -0
- package/dist/libsql/libsqlQuerierPool.js +19 -0
- package/dist/libsql/libsqlQuerierPool.js.map +1 -0
- package/dist/neon/index.d.ts +3 -0
- package/dist/neon/index.d.ts.map +1 -0
- package/dist/neon/index.js +3 -0
- package/dist/neon/index.js.map +1 -0
- package/dist/neon/neonQuerier.d.ts +18 -0
- package/dist/neon/neonQuerier.d.ts.map +1 -0
- package/dist/neon/neonQuerier.js +40 -0
- package/dist/neon/neonQuerier.js.map +1 -0
- package/dist/neon/neonQuerierPool.d.ts +11 -0
- package/dist/neon/neonQuerierPool.d.ts.map +1 -0
- package/dist/neon/neonQuerierPool.js +17 -0
- package/dist/neon/neonQuerierPool.js.map +1 -0
- package/package.json +16 -3
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
|
-
|
|
6
|
+
## [3.4.2](https://github.com/rogerpadilla/uql/compare/@uql/core@3.4.1...@uql/core@3.4.2) (2025-12-31)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @uql/core
|
|
9
9
|
|
package/README.md
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://uql.app)
|
|
4
4
|
|
|
5
|
-
[](https://github.com/rogerpadilla/uql) [](https://github.com/rogerpadilla/uql) [](https://coveralls.io/github/rogerpadilla/uql?branch=main) [](https://github.com/rogerpadilla/uql/blob/main/LICENSE) [](https://www.npmjs.com/package/@uql/core)
|
|
6
6
|
|
|
7
|
-
[UQL](https://uql.app) is the [smartest ORM](https://medium.com/@rogerpadillac/in-search-of-the-perfect-orm-e01fcc9bce3d) for TypeScript
|
|
7
|
+
**[UQL](https://uql.app)** is the [smartest ORM](https://medium.com/@rogerpadillac/in-search-of-the-perfect-orm-e01fcc9bce3d) for TypeScript. It is engineered to be **fast**, **safe**, and **universally compatible**.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Uses a consistent API for distinct databases, including PostgreSQL, MySQL, MariaDB, and SQLite (inspired by MongoDB glorious syntax).
|
|
9
|
+
- **Runs Everywhere**: Node.js, Bun, Deno, Cloudflare Workers, Electron, React Native, and even the Browser.
|
|
10
|
+
- **Unified API**: A consistent, expressive query interface for PostgreSQL, MySQL, MariaDB, SQLite, LibSQL, Neon, Cloudflare D1, and MongoDB (inspired by its glorious syntax).
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
|
|
@@ -33,7 +32,7 @@ See [this article](https://medium.com/@rogerpadillac/in-search-of-the-perfect-or
|
|
|
33
32
|
|
|
34
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).
|
|
35
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.
|
|
36
|
-
- **Unified API across Databases**: Write once, run anywhere. Seamlessly switch between `PostgreSQL`, `MySQL`, `MariaDB`, `SQLite`, and even `MongoDB`.
|
|
35
|
+
- **Unified API across Databases**: Write once, run anywhere. Seamlessly switch between `PostgreSQL`, `MySQL`, `MariaDB`, `SQLite`, `LibSQL`, `Neon`, `Cloudflare D1`, and even `MongoDB`.
|
|
37
36
|
- **Serializable JSON Syntax**: Queries can be expressed as `100%` valid `JSON`, allowing them to be easily transported from frontend to backend.
|
|
38
37
|
- **Naming Strategies**: Effortlessly translate between TypeScript `CamelCase` and database `snake_case` (or any custom format) with a pluggable system.
|
|
39
38
|
- **Built-in Serialization**: A centralized task queue and `@Serialized()` decorator ensure database operations are thread-safe and race-condition free by default.
|
|
@@ -56,12 +55,15 @@ See [this article](https://medium.com/@rogerpadillac/in-search-of-the-perfect-or
|
|
|
56
55
|
|
|
57
56
|
2. Install one of the specific adapters for your database:
|
|
58
57
|
|
|
59
|
-
| Database
|
|
60
|
-
|
|
|
61
|
-
| `PostgreSQL` | `pg`
|
|
62
|
-
| `
|
|
63
|
-
| `MariaDB`
|
|
64
|
-
| `
|
|
58
|
+
| Database | Driver
|
|
59
|
+
| :--- | :---
|
|
60
|
+
| `PostgreSQL` (incl. CockroachDB, YugabyteDB) | `pg`
|
|
61
|
+
| `MySQL` (incl. TiDB, Aurora) | `mysql2`
|
|
62
|
+
| `MariaDB` | `mariadb`
|
|
63
|
+
| `SQLite` | `better-sqlite3`
|
|
64
|
+
| `Cloudflare D1` | `Native Binding`
|
|
65
|
+
| `LibSQL` (Turso) | `@libsql/client`
|
|
66
|
+
| `Neon` (Serverless Postgres) | `@neondatabase/serverless`
|
|
65
67
|
|
|
66
68
|
|
|
67
69
|
|
|
@@ -203,14 +205,9 @@ export const pool = new PgQuerierPool(
|
|
|
203
205
|
|
|
204
206
|
## 4. Manipulate the data
|
|
205
207
|
|
|
206
|
-
UQL provides multiple ways to interact with your data, from
|
|
207
|
-
|
|
208
|
-
### Using Repositories (Recommended)
|
|
209
|
-
|
|
210
|
-
Repositories provide a clean, Data-Mapper style interface for your entities.
|
|
208
|
+
UQL provides multiple ways to interact with your data, from generic `Queriers` (that works with any entity) to entity-specific `Repositories`.
|
|
211
209
|
|
|
212
210
|
```ts
|
|
213
|
-
import { GenericRepository } from '@uql/core';
|
|
214
211
|
import { User } from './shared/models/index.js';
|
|
215
212
|
import { pool } from './shared/orm.js';
|
|
216
213
|
|
|
@@ -218,10 +215,8 @@ import { pool } from './shared/orm.js';
|
|
|
218
215
|
const querier = await pool.getQuerier();
|
|
219
216
|
|
|
220
217
|
try {
|
|
221
|
-
const userRepository = new GenericRepository(User, querier);
|
|
222
|
-
|
|
223
218
|
// Advanced querying with relations and virtual fields
|
|
224
|
-
const users = await
|
|
219
|
+
const users = await querier.findMany(User, {
|
|
225
220
|
$select: {
|
|
226
221
|
id: true,
|
|
227
222
|
name: true,
|
|
@@ -246,14 +241,13 @@ try {
|
|
|
246
241
|
UQL's query syntax is context-aware. When you query a relation, the available fields and operators are automatically suggested and validated based on that related entity.
|
|
247
242
|
|
|
248
243
|
```ts
|
|
249
|
-
import { GenericRepository } from '@uql/core';
|
|
250
244
|
import { pool } from './shared/orm.js';
|
|
251
245
|
import { User } from './shared/models/index.js';
|
|
252
246
|
|
|
253
|
-
const
|
|
254
|
-
const userRepository = new GenericRepository(User, querier);
|
|
247
|
+
const querier = await pool.getQuerier();
|
|
255
248
|
|
|
256
|
-
|
|
249
|
+
try {
|
|
250
|
+
const authorsWithPopularPosts = await querier.findMany(User, {
|
|
257
251
|
$select: {
|
|
258
252
|
id: true,
|
|
259
253
|
name: true,
|
|
@@ -275,7 +269,9 @@ const authorsWithPopularPosts = await pool.transaction(async (querier) => {
|
|
|
275
269
|
name: { $istartsWith: 'a' }
|
|
276
270
|
}
|
|
277
271
|
});
|
|
278
|
-
}
|
|
272
|
+
} finally {
|
|
273
|
+
await querier.release();
|
|
274
|
+
}
|
|
279
275
|
```
|
|
280
276
|
|
|
281
277
|
### Advanced: Virtual Fields & Raw SQL
|