tspace-mysql 1.6.6-dev.1 → 1.6.6-dev.1.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/README.md +21 -0
- package/build/cli/models/model.js +2 -0
- package/build/cli/models/model.js.map +1 -1
- package/build/lib/core/Builder.d.ts +6 -0
- package/build/lib/core/Builder.js +9 -1
- package/build/lib/core/Builder.js.map +1 -1
- package/build/lib/core/Handlers/Relation.js +42 -34
- package/build/lib/core/Handlers/Relation.js.map +1 -1
- package/build/lib/core/Handlers/State.d.ts +2 -0
- package/build/lib/core/Handlers/State.js +2 -0
- package/build/lib/core/Handlers/State.js.map +1 -1
- package/build/lib/core/Model.d.ts +35 -1
- package/build/lib/core/Model.js +75 -16
- package/build/lib/core/Model.js.map +1 -1
- package/build/lib/utils/index.js.map +1 -1
- package/build/tests/Benchmark.test.d.ts +1 -0
- package/build/tests/Benchmark.test.js +132 -0
- package/build/tests/Benchmark.test.js.map +1 -0
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ npm install tspace-mysql -g
|
|
|
64
64
|
- [Observer](#observer)
|
|
65
65
|
- [Logger](#logger)
|
|
66
66
|
- [Hooks](#hooks)
|
|
67
|
+
- [Global Scope](#global-scope)
|
|
67
68
|
- [SoftDelete](#softdelete)
|
|
68
69
|
- [Schema](#schema)
|
|
69
70
|
- [Schema Model](#schema-model)
|
|
@@ -1434,6 +1435,26 @@ class User extends Model {
|
|
|
1434
1435
|
|
|
1435
1436
|
```
|
|
1436
1437
|
|
|
1438
|
+
### Global Scope
|
|
1439
|
+
```js
|
|
1440
|
+
|
|
1441
|
+
class User extends Model {
|
|
1442
|
+
constructor() {
|
|
1443
|
+
super()
|
|
1444
|
+
|
|
1445
|
+
// Every query will have the global scope applied.
|
|
1446
|
+
this.globalScope((query : User) => {
|
|
1447
|
+
return query.select('id').where('id' , '>' , 10).orderBy('id')
|
|
1448
|
+
})
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
const user = await new User().findMany()
|
|
1453
|
+
|
|
1454
|
+
// SELECT `users`.`id` FROM `users` WHERE `users`.`id` > '10' ORDER BY `users`.`id` ASC LIMIT 1
|
|
1455
|
+
|
|
1456
|
+
```
|
|
1457
|
+
|
|
1437
1458
|
### SoftDelete
|
|
1438
1459
|
|
|
1439
1460
|
```js
|
|
@@ -22,6 +22,7 @@ class ${model} extends Model {
|
|
|
22
22
|
*/
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
|
|
25
26
|
module.exports = ${model};
|
|
26
27
|
module.exports = { ${model} };
|
|
27
28
|
`;
|
|
@@ -46,6 +47,7 @@ class ${model} extends Model {
|
|
|
46
47
|
*/
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
|
|
49
51
|
export { ${model} }
|
|
50
52
|
export default ${model}
|
|
51
53
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/cli/models/model.ts"],"names":[],"mappings":";;AAAA,MAAM,KAAK,GAAG,CAAC,EAAE,KAAK,EAAG,GAAG,EAAG,IAAI,EAAmD,EAAE,EAAE;IAExF,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,EAAC,EAAE,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC;QAEjD,KAAK,IAAK,CAAC,CAAC,CAAC;YACjB,OAAO,8BAA8B,GAAG;;QAEhC,KAAK
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/cli/models/model.ts"],"names":[],"mappings":";;AAAA,MAAM,KAAK,GAAG,CAAC,EAAE,KAAK,EAAG,GAAG,EAAG,IAAI,EAAmD,EAAE,EAAE;IAExF,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,EAAC,EAAE,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC;QAEjD,KAAK,IAAK,CAAC,CAAC,CAAC;YACjB,OAAO,8BAA8B,GAAG;;QAEhC,KAAK;;;;;;;;;;;;;;;;;;mBAkBM,KAAK;qBACH,KAAK;CACzB,CAAA;QACG,CAAC;QAED,KAAK,IAAK,CAAC,CAAC,CAAC;YACjB,OAAO,0BAA0B,GAAG;;QAE5B,KAAK;;;;;;;;;;;;;;;;;;WAkBF,KAAK;iBACC,KAAK;CACrB,CAAA;QACG,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,kBAAe,KAAK,CAAA"}
|
|
@@ -23,6 +23,12 @@ declare class Builder extends AbstractBuilder {
|
|
|
23
23
|
groupBy?: boolean;
|
|
24
24
|
having?: boolean;
|
|
25
25
|
}): this;
|
|
26
|
+
/**
|
|
27
|
+
* The 'getQueries' method is used to retrieve the raw SQL queries that would be executed.
|
|
28
|
+
*
|
|
29
|
+
* @returns {string} return sql query
|
|
30
|
+
*/
|
|
31
|
+
getQueries(): string[];
|
|
26
32
|
/**
|
|
27
33
|
* The 'distinct' method is used to apply the DISTINCT keyword to a database query.
|
|
28
34
|
*
|
|
@@ -64,6 +64,14 @@ class Builder extends AbstractBuilder_1.AbstractBuilder {
|
|
|
64
64
|
this.$state.set('OFFSET', '');
|
|
65
65
|
return this;
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The 'getQueries' method is used to retrieve the raw SQL queries that would be executed.
|
|
69
|
+
*
|
|
70
|
+
* @returns {string} return sql query
|
|
71
|
+
*/
|
|
72
|
+
getQueries() {
|
|
73
|
+
return this.$state.get('QUERIES');
|
|
74
|
+
}
|
|
67
75
|
/**
|
|
68
76
|
* The 'distinct' method is used to apply the DISTINCT keyword to a database query.
|
|
69
77
|
*
|
|
@@ -3441,7 +3449,7 @@ class Builder extends AbstractBuilder_1.AbstractBuilder {
|
|
|
3441
3449
|
bindOrderBy(this.$state.get('ORDER_BY')),
|
|
3442
3450
|
this.$state.get('LIMIT'),
|
|
3443
3451
|
this.$state.get('OFFSET')
|
|
3444
|
-
]);
|
|
3452
|
+
]).trimEnd();
|
|
3445
3453
|
};
|
|
3446
3454
|
const insert = () => buildSQL([this.$state.get('INSERT')]);
|
|
3447
3455
|
const update = () => {
|