forj 0.1.9 → 0.1.10
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/package.json +2 -2
- package/src/model.ts +4 -2
- package/src/query-builder.ts +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forj",
|
|
3
3
|
"description": "SQLite ORM and Query Builder whitout dependencies",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.10",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"files": ["src"],
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@aws-sdk/lib-dynamodb": "^3.1003.0",
|
|
24
24
|
"pathe": "^2.0",
|
|
25
25
|
"pluralize": "^8.0",
|
|
26
|
-
"t0n": "^0.1.
|
|
26
|
+
"t0n": "^0.1.13",
|
|
27
27
|
"zod": "^4.3.6"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
package/src/model.ts
CHANGED
|
@@ -38,7 +38,8 @@ export default abstract class Model<TB extends keyof DB, DB> {
|
|
|
38
38
|
M extends typeof Model<TB, DB>,
|
|
39
39
|
I extends InstanceType<M>,
|
|
40
40
|
T extends I['$TShape'],
|
|
41
|
-
|
|
41
|
+
C extends keyof T
|
|
42
|
+
>(this: M, data: Record<C, Value>) {
|
|
42
43
|
return this.builder<I['$DBShape'], T>().insert(data)
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -46,7 +47,8 @@ export default abstract class Model<TB extends keyof DB, DB> {
|
|
|
46
47
|
M extends typeof Model<TB, DB>,
|
|
47
48
|
I extends InstanceType<M>,
|
|
48
49
|
T extends I['$TShape'],
|
|
49
|
-
|
|
50
|
+
C extends keyof T
|
|
51
|
+
>(this: M, data: Record<C, Value>) {
|
|
50
52
|
return this.builder<I['$DBShape'], T>().update(data)
|
|
51
53
|
}
|
|
52
54
|
|
package/src/query-builder.ts
CHANGED
|
@@ -77,7 +77,7 @@ export default class QueryBuilder<
|
|
|
77
77
|
return await this.#pipe?.run(this)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
#setType(type: QueryType, data?: Partial<Record<
|
|
80
|
+
#setType<K extends keyof T>(type: QueryType, data?: Partial<Record<K, Value>>) {
|
|
81
81
|
this.#type = type
|
|
82
82
|
if (data) {
|
|
83
83
|
this.#keys = Object.keys(data)
|
|
@@ -87,14 +87,14 @@ export default class QueryBuilder<
|
|
|
87
87
|
return this
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
insert(data: Partial<Record<
|
|
90
|
+
insert<K extends keyof T>(data: Partial<Record<K, Value>>) {
|
|
91
91
|
if (this.#opts.timestamps || this.#opts.createdAt) // @ts-ignore
|
|
92
92
|
data.created_at = Timestamp.now()
|
|
93
93
|
|
|
94
94
|
return this.#setType(types.INSERT, data)
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
update(data: Partial<Record<
|
|
97
|
+
update<K extends keyof T>(data: Partial<Record<K, Value>>) {
|
|
98
98
|
if (this.#opts.timestamps || this.#opts.updatedAt) // @ts-ignore
|
|
99
99
|
data.updated_at = Timestamp.now()
|
|
100
100
|
|