@anephenix/objection-relations 0.0.17 → 0.0.19

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/README.md +26 -0
  2. package/package.json +2 -7
package/README.md CHANGED
@@ -61,6 +61,32 @@ The helper function will do the following:
61
61
  | ----- | ---------- | ----------- |
62
62
  | User | users | user_id |
63
63
 
64
+ *NOTE*
65
+
66
+ For TypeScript files to resolve correctly in Objection.js, use the model directly instead of the name as a string:
67
+
68
+ ```typescript
69
+ import { ObjectionRelation } from '@anephenix/objection-relations';
70
+ import Address from './Address';
71
+
72
+ class User extends Model {
73
+ static get tableName() {
74
+ return 'users';
75
+ }
76
+
77
+ static get relationMappings() {
78
+ const or = new ObjectionRelation({
79
+ subject: this.name,
80
+ modelPath: __dirname,
81
+ });
82
+ return {
83
+ // This changes from 'Address' to Address
84
+ addresses: or.hasMany(Address),
85
+ };
86
+ }
87
+ }
88
+ ```
89
+
64
90
  ## Dependencies
65
91
 
66
92
  - Node.js
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "version": "0.0.17",
2
+ "name": "@anephenix/objection-relations",
3
+ "version": "0.0.19",
3
4
  "license": "MIT",
4
- "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -14,9 +14,6 @@
14
14
  "dist",
15
15
  "README.md"
16
16
  ],
17
- "engines": {
18
- "node": ">=10"
19
- },
20
17
  "dependencies": {
21
18
  "lodash.snakecase": "^4.1.1",
22
19
  "objection": "^3.1.5",
@@ -57,8 +54,6 @@
57
54
  "pre-commit": "npm run lint && npm test"
58
55
  }
59
56
  },
60
- "name": "@anephenix/objection-relations",
61
- "module": "dist/objection-relations.esm.js",
62
57
  "prettier": {
63
58
  "printWidth": 80,
64
59
  "semi": true,