@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +30 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghom/orm",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
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
- ## Tables
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
- export default new Table({
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
- ## Query
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
- ## Import/extract
75
+ ```typescript
76
+ import user from "./tables/user"
67
77
 
68
- You can transfer the data from one instance of the ORM to another (between two database clients, for example between "pg" and "mysql2").
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
- ```typescript
71
- await orm1.extract()
84
+ return user && user.password === hash
85
+ }
72
86
  ```
73
87
 
74
- ```typescript
75
- await orm2.import()
76
- ```
88
+ ## Future features
77
89
 
78
- The SQL structure isn't transferred, only the data. You must copy the table files to the other project.
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