masquerade-orm 0.1.1 → 0.8.0
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 +6 -5
- package/docs/in-depth-class-definitions.md +17 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
+
|
|
2
3
|
<a href="#">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/MasqueradeORM/MasqueradeORM/releases/download/0.1.0/DARK-THEME-LOGO-transperent-bg.png">
|
|
6
|
+
<source media="(prefers-color-scheme: light)" srcset="https://github.com/MasqueradeORM/MasqueradeORM/releases/download/0.1.0/LIGHT-THEME-LOGO-transperent-bg.png">
|
|
7
|
+
<img style="max-width: 33%; height: auto;" alt="MasqueradeORM Logo" src="https://github.com/MasqueradeORM/MasqueradeORM/releases/download/0.1.0/DARK-THEME-LOGO-transperent-bg.png">
|
|
8
|
+
</picture>
|
|
8
9
|
</a>
|
|
9
10
|
<br><br>
|
|
10
11
|
<a href="">
|
|
@@ -95,7 +95,7 @@ const newInstance = new ExampleClass()
|
|
|
95
95
|
newInstance.json.stringArr.push('d')
|
|
96
96
|
newInstance.jsonArr.stringArr.push('d')
|
|
97
97
|
// The below mutation IS an assigment, but it is
|
|
98
|
-
// nested, and therefore
|
|
98
|
+
// nested, and therefore also won't be persisted.
|
|
99
99
|
newInstance.json.nestedObj.someProp = 'hola mundo'
|
|
100
100
|
|
|
101
101
|
// First solution - property assigment
|
|
@@ -174,13 +174,26 @@ this means *ClassD's* table will inherit columns from both *ClassA* and *ClassB*
|
|
|
174
174
|
## 4) Guidelines for Classes
|
|
175
175
|
|
|
176
176
|
Classes that are connected to the ORM and mapped to database tables must follow a few simple rules:
|
|
177
|
-
- **Rule 1:** Class must either directly extend Entity (imported from the package) or extend another class that has Entity as an ancestor.
|
|
178
|
-
- **Rule 2:** Class properties must have a single
|
|
179
|
-
|
|
177
|
+
- **Rule 1:** Class must either directly extend `Entity` (imported from the package) or extend another class that has `Entity` as an ancestor.
|
|
178
|
+
- **Rule 2:** Class properties must have a single **“main” type**, which can be a `primitive`, an `object`, or a **class that follows **Rule 1****.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
- **Rule 3:** Class names must be PascalCased.
|
|
180
182
|
- **Rule 4:** Class property names must be camelCased.
|
|
181
183
|
|
|
182
184
|
As long as these rules are adhered to, the class is valid.
|
|
183
185
|
|
|
186
|
+
**“Main” Type Mapping**
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
class EntityExtendingClass extends Entity {
|
|
190
|
+
// class properties + constructor
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
string[] // main type 'string'
|
|
194
|
+
(string | undefined)[] | undefined // main type 'string'
|
|
195
|
+
EntityExtendingClass[] | undefined // main type 'EntityExtendingClass'
|
|
196
|
+
```
|
|
184
197
|
|
|
185
198
|
<br>
|
|
186
199
|
<div align="center">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masquerade-orm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Lightweight ORM compatible with SQLite and Postgresql in Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"./package.json": "./package.json"
|
|
34
34
|
},
|
|
35
35
|
"bin": {
|
|
36
|
-
"orm-ts-setup": "
|
|
36
|
+
"orm-ts-setup": "bin/universalTsInit.js"
|
|
37
37
|
},
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"author": "Masquerade-Orm",
|