tspace-mysql 1.8.2-beta.2 → 1.8.3
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 +12 -8
- package/build/lib/core/Builder.d.ts +26 -26
- package/build/lib/core/Builder.js +1092 -1014
- package/build/lib/core/Builder.js.map +1 -1
- package/build/lib/core/DB.d.ts +38 -38
- package/build/lib/core/DB.js +117 -113
- package/build/lib/core/DB.js.map +1 -1
- package/build/lib/core/Model.d.ts +83 -83
- package/build/lib/core/Model.js +1328 -1185
- package/build/lib/core/Model.js.map +1 -1
- package/build/lib/{connection/index.js → core/Pool.js} +1 -1
- package/build/lib/core/Pool.js.map +1 -0
- package/build/lib/core/index.d.ts +12 -12
- package/build/lib/core/index.js +3 -3
- package/build/lib/core/index.js.map +1 -1
- package/package.json +1 -1
- package/build/lib/connection/index.js.map +0 -1
- /package/build/lib/{connection/index.d.ts → core/Pool.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -3323,17 +3323,21 @@ import { Phone } from '../Models/Phone'
|
|
|
3323
3323
|
const userRepository = Repository(User)
|
|
3324
3324
|
|
|
3325
3325
|
const userHasPhones = await userRepository.findOne({
|
|
3326
|
-
select :
|
|
3327
|
-
|
|
3326
|
+
select : {
|
|
3327
|
+
id : true,
|
|
3328
|
+
name : true,
|
|
3329
|
+
username : true,
|
|
3330
|
+
phone : {
|
|
3331
|
+
id : true,
|
|
3332
|
+
user_id : true,
|
|
3333
|
+
name: true
|
|
3334
|
+
}
|
|
3335
|
+
},
|
|
3336
|
+
where : {
|
|
3328
3337
|
id: 1
|
|
3329
3338
|
},
|
|
3330
3339
|
relations: {
|
|
3331
3340
|
phone: {
|
|
3332
|
-
select : {
|
|
3333
|
-
id : true,
|
|
3334
|
-
userId : true,
|
|
3335
|
-
name: true
|
|
3336
|
-
}
|
|
3337
3341
|
user : true
|
|
3338
3342
|
}
|
|
3339
3343
|
}
|
|
@@ -3342,7 +3346,7 @@ const userHasPhones = await userRepository.findOne({
|
|
|
3342
3346
|
const phoneRepository = Repository(Phone)
|
|
3343
3347
|
|
|
3344
3348
|
const phoneBelongUser = await phoneRepository.findOne({
|
|
3345
|
-
select :
|
|
3349
|
+
select : '*',
|
|
3346
3350
|
where : {
|
|
3347
3351
|
id: 1
|
|
3348
3352
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbstractBuilder } from
|
|
2
|
-
import { Join } from
|
|
3
|
-
import { TPagination, TConnectionOptions, TConnection, TConnectionTransaction } from
|
|
1
|
+
import { AbstractBuilder } from "./Abstracts/AbstractBuilder";
|
|
2
|
+
import { Join } from "./Join";
|
|
3
|
+
import { TPagination, TConnectionOptions, TConnection, TConnectionTransaction } from "../types";
|
|
4
4
|
declare class Builder extends AbstractBuilder {
|
|
5
5
|
constructor();
|
|
6
6
|
/**
|
|
@@ -145,7 +145,7 @@ declare class Builder extends AbstractBuilder {
|
|
|
145
145
|
* @param {string} type - The types 'object' | 'array'
|
|
146
146
|
* @returns {this} this
|
|
147
147
|
*/
|
|
148
|
-
returnType(type:
|
|
148
|
+
returnType(type: "object" | "array"): this;
|
|
149
149
|
/**
|
|
150
150
|
* The 'pluck' method is used to retrieve the value of a single column from the first result of a query.
|
|
151
151
|
*
|
|
@@ -685,7 +685,7 @@ declare class Builder extends AbstractBuilder {
|
|
|
685
685
|
* .get()
|
|
686
686
|
* @returns {this}
|
|
687
687
|
*/
|
|
688
|
-
joinSubQuery({ localKey, foreignKey, sql }: {
|
|
688
|
+
joinSubQuery({ localKey, foreignKey, sql, }: {
|
|
689
689
|
localKey: string;
|
|
690
690
|
foreignKey: string;
|
|
691
691
|
sql: string;
|
|
@@ -698,7 +698,7 @@ declare class Builder extends AbstractBuilder {
|
|
|
698
698
|
* @param {string?} order by default order = 'asc' but you can used 'asc' or 'desc'
|
|
699
699
|
* @returns {this}
|
|
700
700
|
*/
|
|
701
|
-
orderBy(column: string, order?:
|
|
701
|
+
orderBy(column: string, order?: "ASC" | "asc" | "DESC" | "desc"): this;
|
|
702
702
|
/**
|
|
703
703
|
* The 'orderByRaw' method is used to specify the order in which the results of a database query should be sorted.
|
|
704
704
|
*
|
|
@@ -709,7 +709,7 @@ declare class Builder extends AbstractBuilder {
|
|
|
709
709
|
* @param {string?} order [order=asc] asc, desc
|
|
710
710
|
* @returns {this}
|
|
711
711
|
*/
|
|
712
|
-
orderByRaw(column: string, order?:
|
|
712
|
+
orderByRaw(column: string, order?: "ASC" | "asc" | "DESC" | "desc"): this;
|
|
713
713
|
/**
|
|
714
714
|
* The 'random' method is used to retrieve random records from a database table or to randomize the order in which records are returned in the query result set.
|
|
715
715
|
*
|
|
@@ -1027,7 +1027,7 @@ declare class Builder extends AbstractBuilder {
|
|
|
1027
1027
|
*
|
|
1028
1028
|
* This method is particularly useful for debugging and understanding the SQL queries generated by your application.
|
|
1029
1029
|
* @returns {string}
|
|
1030
|
-
|
|
1030
|
+
*/
|
|
1031
1031
|
toRawSQL(): string;
|
|
1032
1032
|
/**
|
|
1033
1033
|
* The 'getTableName' method is used to get table name
|
|
@@ -1066,13 +1066,13 @@ declare class Builder extends AbstractBuilder {
|
|
|
1066
1066
|
* The 'hook' method is used function when execute returns a result to callback function
|
|
1067
1067
|
* @param {Function} func function for callback result
|
|
1068
1068
|
* @returns {this}
|
|
1069
|
-
|
|
1069
|
+
*/
|
|
1070
1070
|
hook(func: Function): this;
|
|
1071
1071
|
/**
|
|
1072
1072
|
* The 'before' method is used function when execute returns a result to callback function
|
|
1073
1073
|
* @param {Function} func function for callback result
|
|
1074
1074
|
* @returns {this}
|
|
1075
|
-
|
|
1075
|
+
*/
|
|
1076
1076
|
before(func: Function): this;
|
|
1077
1077
|
/**
|
|
1078
1078
|
*
|
|
@@ -1338,20 +1338,20 @@ declare class Builder extends AbstractBuilder {
|
|
|
1338
1338
|
*/
|
|
1339
1339
|
getGroupBy(column: string): Promise<Map<string | number, any[]>>;
|
|
1340
1340
|
/**
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1341
|
+
* The 'findGroupBy' method is used to execute a database query and retrieve the result set that matches the query conditions.
|
|
1342
|
+
*
|
|
1343
|
+
* It retrieves multiple records from a database table based on the criteria specified in the query.
|
|
1344
|
+
*
|
|
1345
|
+
* It returns record to new Map
|
|
1346
|
+
* @param {string} column
|
|
1347
|
+
* @example
|
|
1348
|
+
* const results = await new DB('posts')
|
|
1349
|
+
* .findGroupBy('user_id')
|
|
1350
|
+
*
|
|
1351
|
+
* // you can find with user id in the results
|
|
1352
|
+
* const postsByUserId1 = results.get(1)
|
|
1353
|
+
* @returns {promise<Array>}
|
|
1354
|
+
*/
|
|
1355
1355
|
findGroupBy(column: string): Promise<Map<string | number, any[]>>;
|
|
1356
1356
|
/**
|
|
1357
1357
|
* The 'save' method is used to persist a new 'Model' or new 'DB' instance or update an existing model instance in the database.
|
|
@@ -1444,7 +1444,7 @@ declare class Builder extends AbstractBuilder {
|
|
|
1444
1444
|
* @property {boolean} option.force
|
|
1445
1445
|
* @returns {promise<boolean>}
|
|
1446
1446
|
*/
|
|
1447
|
-
truncate({ force }?: {
|
|
1447
|
+
truncate({ force, }?: {
|
|
1448
1448
|
force?: boolean;
|
|
1449
1449
|
}): Promise<boolean>;
|
|
1450
1450
|
/**
|
|
@@ -1493,7 +1493,7 @@ declare class Builder extends AbstractBuilder {
|
|
|
1493
1493
|
protected _resultHandlerExists(data: any): any;
|
|
1494
1494
|
whereReference(tableAndLocalKey: string, tableAndForeignKey?: string): this;
|
|
1495
1495
|
protected _queryStatement(sql: string): Promise<any[]>;
|
|
1496
|
-
protected _actionStatement({ sql, returnId }: {
|
|
1496
|
+
protected _actionStatement({ sql, returnId, }: {
|
|
1497
1497
|
sql: string;
|
|
1498
1498
|
returnId?: boolean;
|
|
1499
1499
|
}): Promise<any>;
|