uql-orm 0.107.1 → 0.107.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/README.md +11 -4
- package/package.json +1 -1
- package/skills/uql-orm/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
32
|
```sh
|
|
33
|
-
npm install uql-orm pg
|
|
33
|
+
npm install uql-orm pg
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
That is the whole install ([setup](https://uql-orm.dev/getting-started)). No compiler flags and no `reflect-metadata`; the decorators are the [TC39 standard spec](https://uql-orm.dev/entities/basic), and an entity can be declared as data instead, its row type derived, via [`defineEntity`](https://uql-orm.dev/entities/define-entity).
|
|
36
|
+
That is the whole install, `pg` swapped for your database's driver: `mysql2`, `mariadb`, `better-sqlite3`, `mongodb`, `@tursodatabase/serverless` or `@libsql/client` ([setup](https://uql-orm.dev/getting-started)). No compiler flags and no `reflect-metadata`; the decorators are the [TC39 standard spec](https://uql-orm.dev/entities/basic), and an entity can be declared as data instead, its row type derived, via [`defineEntity`](https://uql-orm.dev/entities/define-entity).
|
|
37
37
|
|
|
38
38
|
<a href="https://uql-orm.dev">
|
|
39
39
|
<picture>
|
|
@@ -86,6 +86,8 @@ export class Post {
|
|
|
86
86
|
Or declare one as data, its row type derived:
|
|
87
87
|
|
|
88
88
|
```ts
|
|
89
|
+
import { defineEntity, f } from 'uql-orm';
|
|
90
|
+
|
|
89
91
|
export const Post = defineEntity({
|
|
90
92
|
name: 'Post',
|
|
91
93
|
fields: {
|
|
@@ -94,7 +96,12 @@ export const Post = defineEntity({
|
|
|
94
96
|
likes: f.number().nullable(),
|
|
95
97
|
authorId: f.number().nullable(),
|
|
96
98
|
},
|
|
97
|
-
}).relations((rel) => ({
|
|
99
|
+
}).relations((rel) => ({
|
|
100
|
+
author: () => rel.manyToOne(User, { references: (post) => post.authorId }),
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
// One name for the entity and its rows, as a class has: a function takes `post: Post`.
|
|
104
|
+
export type Post = InstanceType<typeof Post>;
|
|
98
105
|
```
|
|
99
106
|
|
|
100
107
|
### 2. A pool, and the migrations it drives
|
|
@@ -112,7 +119,7 @@ export default { pool, entities: [User, Post] } satisfies Config;
|
|
|
112
119
|
|
|
113
120
|
```sh
|
|
114
121
|
npm i -D tsx # Node only: the CLI loads uql.config.ts through it
|
|
115
|
-
npx uql-migrate generate:entities initial #
|
|
122
|
+
npx uql-migrate generate:entities initial # writes the diff against the database, to review
|
|
116
123
|
npx uql-migrate up # applies it
|
|
117
124
|
```
|
|
118
125
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://uql-orm.dev",
|
|
4
4
|
"description": "JSON-native TypeScript ORM for Bun, Browsers, Edge, Node, Workers. Supports PostgreSQL, PGlite, MySQL, MariaDB, SQLite, CockroachDB, SQL Server, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.107.
|
|
6
|
+
"version": "0.107.2",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=22.18"
|
package/skills/uql-orm/SKILL.md
CHANGED
|
@@ -123,7 +123,7 @@ Both forms are supported, mix them per entity, and produce the same queries and
|
|
|
123
123
|
- Cons
|
|
124
124
|
- Relations are thunks declared after the columns, and `.relations()` comes last (only `.filters()` may follow it).
|
|
125
125
|
- No column-level foreign keys: a shared key is a relation helper, and an eager read across two entities can create an inference cycle (TS7022).
|
|
126
|
-
-
|
|
126
|
+
- Naming its row type as `X`, as a class does, takes a `type X = InstanceType<typeof X>` alias beside it.
|
|
127
127
|
- No class to annotate or extend: inheritance uses `extends` naming the base.
|
|
128
128
|
- Newer and less used.
|
|
129
129
|
|