masquerade-orm 0.1.0 → 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 +15 -6
- package/docs/in-depth-class-definitions.md +17 -4
- package/package.json +19 -3
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="">
|
|
@@ -15,7 +16,8 @@
|
|
|
15
16
|
</div>
|
|
16
17
|
|
|
17
18
|
**MasqueradeORM** is a lightweight ORM for Node.js that works seamlessly with both TypeScript and JavaScript.
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
Its goal is to hide SQL complexity while letting you work naturally in JS/TS syntax.
|
|
19
21
|
Instead of forcing you into ORM-specific models, metadata systems, or decorators, MasqueradeORM lets you use **your own classes** directly, exactly as you normally would.
|
|
20
22
|
|
|
21
23
|
MasqueradeORM improves readability, maintainability, and workflow simplicity through a unified coding approach and extremely minimal setup.
|
|
@@ -27,6 +29,13 @@ MasqueradeORM currently supports the following SQL clients:
|
|
|
27
29
|
- **SQLite**
|
|
28
30
|
- **Postgresql**
|
|
29
31
|
|
|
32
|
+
|
|
33
|
+
# Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install masquerade-orm
|
|
37
|
+
```
|
|
38
|
+
|
|
30
39
|
# Features
|
|
31
40
|
- **Effortless setup** - no ORM-specific structures; just use your classes.
|
|
32
41
|
- **Zero schema planning** - tables and schema are generated automatically.
|
|
@@ -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,8 +1,24 @@
|
|
|
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
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"orm",
|
|
7
|
+
"TypeScript",
|
|
8
|
+
"TS",
|
|
9
|
+
"JavaScript",
|
|
10
|
+
"JS",
|
|
11
|
+
"NodeJs",
|
|
12
|
+
"sqlite",
|
|
13
|
+
"postgresql",
|
|
14
|
+
"postgres",
|
|
15
|
+
"database",
|
|
16
|
+
"db",
|
|
17
|
+
"SQL",
|
|
18
|
+
"lightweight",
|
|
19
|
+
"typeorm",
|
|
20
|
+
"prisma"
|
|
21
|
+
],
|
|
6
22
|
"repository": {
|
|
7
23
|
"type": "git",
|
|
8
24
|
"url": "Masquerade-Orm"
|
|
@@ -17,7 +33,7 @@
|
|
|
17
33
|
"./package.json": "./package.json"
|
|
18
34
|
},
|
|
19
35
|
"bin": {
|
|
20
|
-
"orm-ts-setup": "
|
|
36
|
+
"orm-ts-setup": "bin/universalTsInit.js"
|
|
21
37
|
},
|
|
22
38
|
"license": "MIT",
|
|
23
39
|
"author": "Masquerade-Orm",
|