@ghom/orm 1.7.1 → 1.7.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/package.json +1 -1
- package/readme.md +30 -12
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -22,9 +22,12 @@ const orm = new ORM({
|
|
|
22
22
|
logger: console,
|
|
23
23
|
loggerColors: { ... }
|
|
24
24
|
})
|
|
25
|
+
|
|
26
|
+
// start handling of tables
|
|
27
|
+
await orm.init()
|
|
25
28
|
```
|
|
26
29
|
|
|
27
|
-
##
|
|
30
|
+
## Add tables
|
|
28
31
|
|
|
29
32
|
The tables are automatically loaded from the `location` directory.
|
|
30
33
|
|
|
@@ -33,7 +36,12 @@ The tables are automatically loaded from the `location` directory.
|
|
|
33
36
|
|
|
34
37
|
import { Table } from "@ghom/orm"
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
interface User {
|
|
40
|
+
username: string
|
|
41
|
+
password: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default new Table<User>({
|
|
37
45
|
name: "user",
|
|
38
46
|
|
|
39
47
|
// the higher the priority, the earlier the table is compiled
|
|
@@ -59,20 +67,30 @@ export default new Table({
|
|
|
59
67
|
})
|
|
60
68
|
```
|
|
61
69
|
|
|
62
|
-
##
|
|
70
|
+
## Launch a query
|
|
63
71
|
|
|
64
|
-
For more information about the query builder, see [knexjs.org](https://knexjs.org/).
|
|
72
|
+
For more information about the query builder, see [knexjs.org](https://knexjs.org/).
|
|
73
|
+
You can launch a SQL query on a table like that
|
|
65
74
|
|
|
66
|
-
|
|
75
|
+
```typescript
|
|
76
|
+
import user from "./tables/user"
|
|
67
77
|
|
|
68
|
-
|
|
78
|
+
export async function compareHash(username, hash): Promise<boolean> {
|
|
79
|
+
const user = await user.query
|
|
80
|
+
.select()
|
|
81
|
+
.where("username", username)
|
|
82
|
+
.first()
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
return user && user.password === hash
|
|
85
|
+
}
|
|
72
86
|
```
|
|
73
87
|
|
|
74
|
-
|
|
75
|
-
await orm2.import()
|
|
76
|
-
```
|
|
88
|
+
## Future features
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
- [ ] Take full control of the table creation
|
|
91
|
+
- [ ] Add backup option
|
|
92
|
+
- [ ] Add admin panel
|
|
93
|
+
- [ ] Add shortcuts for advanced relative queries
|
|
94
|
+
- [ ] Add timed caching system
|
|
95
|
+
- [ ] Make possible to switch the data between all possible clients (pg, mysql, sqlite3)
|
|
96
|
+
- [ ] Add a way to set up timezone directly in the ORM constructor
|