@veap/database 0.1.6 → 0.1.7
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 +10 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -53,23 +53,22 @@ npm install @veap/database better-sqlite3
|
|
|
53
53
|
Create models extending the base `Model` class:
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
|
-
import { Model,
|
|
57
|
-
import type { BelongsTo, HasMany } from "@veap/database";
|
|
56
|
+
import { Model, type BelongsTo, type HasMany } from "@veap/database";
|
|
58
57
|
|
|
59
58
|
export class Author extends Model {
|
|
60
|
-
static override
|
|
59
|
+
static override table = "authors";
|
|
61
60
|
|
|
62
61
|
declare id: string;
|
|
63
62
|
declare name: string;
|
|
64
63
|
declare email: string;
|
|
65
64
|
|
|
66
65
|
public posts(): HasMany<Post> {
|
|
67
|
-
return hasMany(
|
|
66
|
+
return this.hasMany(Post, "author_id");
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
export class Post extends Model {
|
|
72
|
-
static override
|
|
71
|
+
static override table = "posts";
|
|
73
72
|
|
|
74
73
|
declare id: string;
|
|
75
74
|
declare title: string;
|
|
@@ -77,7 +76,7 @@ export class Post extends Model {
|
|
|
77
76
|
declare author_id: string;
|
|
78
77
|
|
|
79
78
|
public author(): BelongsTo<Author> {
|
|
80
|
-
return belongsTo(
|
|
79
|
+
return this.belongsTo(Author, "author_id");
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
```
|
|
@@ -161,9 +160,11 @@ export const app = Application.configure()
|
|
|
161
160
|
|
|
162
161
|
## Subpath Exports
|
|
163
162
|
|
|
164
|
-
| Export Path
|
|
165
|
-
|
|
|
166
|
-
| `@veap/database`
|
|
163
|
+
| Export Path | Content |
|
|
164
|
+
| --------------------------- | ----------------------------------------------------------------------- |
|
|
165
|
+
| `@veap/database` | Core ORM, Model, relations, transactions, schema builder, and providers |
|
|
166
|
+
| `@veap/database/migrations` | Migration runner, `Schema` builder, and migration types |
|
|
167
|
+
| `@veap/database/relations` | Relation classes (`BelongsTo`, `HasMany`, `MorphMany`, `MorphToMany`) |
|
|
167
168
|
|
|
168
169
|
## Documentation
|
|
169
170
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veap/database",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Eloquent-like Active Record ORM powered by Knex with AsyncLocalStorage transactions",
|
|
5
5
|
"bugs": "https://github.com/veapjs/veap-database/issues",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test": "vitest run"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@veap/kernel": "0.
|
|
39
|
+
"@veap/kernel": "0.2.0",
|
|
40
40
|
"better-sqlite3": "^13.0.3",
|
|
41
41
|
"knex": "^3.3.0"
|
|
42
42
|
},
|