tspace-mysql 1.8.0 → 1.8.1-beta.1
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 +152 -30
- package/build/lib/connection/index.d.ts +2 -1
- package/build/lib/connection/index.js +7 -11
- package/build/lib/connection/index.js.map +1 -1
- package/build/lib/core/Abstracts/AbstractBuilder.d.ts +4 -4
- package/build/lib/core/Builder.d.ts +25 -14
- package/build/lib/core/Builder.js +70 -36
- package/build/lib/core/Builder.js.map +1 -1
- package/build/lib/core/Cache/DBCache.d.ts +1 -0
- package/build/lib/core/Cache/DBCache.js +3 -0
- package/build/lib/core/Cache/DBCache.js.map +1 -1
- package/build/lib/core/Cache/MemoryCache.d.ts +7 -6
- package/build/lib/core/Cache/MemoryCache.js +49 -22
- package/build/lib/core/Cache/MemoryCache.js.map +1 -1
- package/build/lib/core/Cache/RedisCache.d.ts +1 -0
- package/build/lib/core/Cache/RedisCache.js +4 -1
- package/build/lib/core/Cache/RedisCache.js.map +1 -1
- package/build/lib/core/Cache/index.d.ts +1 -0
- package/build/lib/core/Cache/index.js +11 -13
- package/build/lib/core/Cache/index.js.map +1 -1
- package/build/lib/core/DB.d.ts +2 -0
- package/build/lib/core/DB.js +16 -13
- package/build/lib/core/DB.js.map +1 -1
- package/build/lib/core/Decorator.d.ts +1 -1
- package/build/lib/core/Handlers/Relation.d.ts +1 -1
- package/build/lib/core/Handlers/Relation.js +15 -15
- package/build/lib/core/Handlers/Relation.js.map +1 -1
- package/build/lib/core/Model.d.ts +27 -15
- package/build/lib/core/Model.js +82 -22
- package/build/lib/core/Model.js.map +1 -1
- package/build/lib/core/Nest/index.d.ts +7 -0
- package/build/lib/core/Nest/index.js +25 -0
- package/build/lib/core/Nest/index.js.map +1 -0
- package/build/lib/core/Operator.d.ts +1 -0
- package/build/lib/core/Operator.js +3 -0
- package/build/lib/core/Operator.js.map +1 -1
- package/build/lib/core/Repository.d.ts +84 -78
- package/build/lib/core/Repository.js +169 -93
- package/build/lib/core/Repository.js.map +1 -1
- package/build/lib/core/Schema.js +3 -7
- package/build/lib/core/Schema.js.map +1 -1
- package/build/lib/core/SqlLike.d.ts +31 -0
- package/build/lib/core/SqlLike.js +167 -0
- package/build/lib/core/SqlLike.js.map +1 -0
- package/build/lib/core/UtilityTypes.d.ts +6 -0
- package/build/lib/core/index.d.ts +4 -0
- package/build/lib/core/index.js +5 -1
- package/build/lib/core/index.js.map +1 -1
- package/build/lib/options/index.d.ts +32 -34
- package/build/lib/options/index.js +11 -17
- package/build/lib/options/index.js.map +1 -1
- package/build/lib/tools/index.d.ts +18 -3
- package/build/lib/tools/index.js +45 -4
- package/build/lib/tools/index.js.map +1 -1
- package/build/lib/{types.d.ts → types/index.d.ts} +28 -16
- package/build/lib/{types.js → types/index.js} +1 -1
- package/build/lib/types/index.js.map +1 -0
- package/build/lib/utils/index.d.ts +1 -0
- package/build/lib/utils/index.js +8 -3
- package/build/lib/utils/index.js.map +1 -1
- package/package.json +22 -21
- package/build/lib/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ npm install tspace-mysql -g
|
|
|
37
37
|
## Basic Usage
|
|
38
38
|
|
|
39
39
|
- [Configuration](#configuration)
|
|
40
|
+
- [SQL Like](#sql-Like)
|
|
40
41
|
- [Query Builder](#query-builder)
|
|
41
42
|
- [Table Name & Alias Name](#table-name--alias-name)
|
|
42
43
|
- [Returning Results](#returning-results)
|
|
@@ -62,6 +63,7 @@ npm install tspace-mysql -g
|
|
|
62
63
|
- [Where Exists Clauses](#where-exists-clauses)
|
|
63
64
|
- [Subquery Where Clauses](#subquery-where-clauses)
|
|
64
65
|
- [Conditional Where Clauses](#conditional-where-clauses)
|
|
66
|
+
- [GetGroupBy](#getgroupby)
|
|
65
67
|
- [Paginating](#paginating)
|
|
66
68
|
- [Insert Statements](#insert-statements)
|
|
67
69
|
- [Update Statements](#update-statements)
|
|
@@ -173,6 +175,71 @@ source db {
|
|
|
173
175
|
charset = utf8mb4
|
|
174
176
|
}
|
|
175
177
|
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## SQL Like
|
|
181
|
+
```js
|
|
182
|
+
import { sql , OP } from 'tspace-mysql'
|
|
183
|
+
|
|
184
|
+
// select
|
|
185
|
+
await sql()
|
|
186
|
+
.select('id','name')
|
|
187
|
+
.from('users')
|
|
188
|
+
.where({
|
|
189
|
+
'name' : 'tspace'
|
|
190
|
+
'id' : OP.in([1,2,3])
|
|
191
|
+
})
|
|
192
|
+
.limit(3)
|
|
193
|
+
.orderBy('name')
|
|
194
|
+
|
|
195
|
+
// insert
|
|
196
|
+
await sql()
|
|
197
|
+
.insert('users')
|
|
198
|
+
.values({
|
|
199
|
+
email : 'tspace@example.com'
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
// insert return data
|
|
203
|
+
await sql()
|
|
204
|
+
.insert('users')
|
|
205
|
+
.values({
|
|
206
|
+
email : 'tspace@example.com'
|
|
207
|
+
})
|
|
208
|
+
.returning({
|
|
209
|
+
id : true,
|
|
210
|
+
email : true,
|
|
211
|
+
enum : true
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
// update
|
|
215
|
+
await sql()
|
|
216
|
+
.update('users')
|
|
217
|
+
.where({
|
|
218
|
+
id : 1
|
|
219
|
+
})
|
|
220
|
+
.set({
|
|
221
|
+
email : 'tspace@example.com'
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
// update return data
|
|
225
|
+
await sql()
|
|
226
|
+
.update('users')
|
|
227
|
+
.where({
|
|
228
|
+
id : 1
|
|
229
|
+
})
|
|
230
|
+
.set({
|
|
231
|
+
email : 'tspace@example.com'
|
|
232
|
+
})
|
|
233
|
+
.returning()
|
|
234
|
+
|
|
235
|
+
//delete
|
|
236
|
+
await sql()
|
|
237
|
+
.delete('users')
|
|
238
|
+
.where({
|
|
239
|
+
id : 1
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
|
|
176
243
|
```
|
|
177
244
|
|
|
178
245
|
## Query Builder
|
|
@@ -204,6 +271,7 @@ How a database query builder works with a simple example using the following:
|
|
|
204
271
|
### Table Name & Alias Name
|
|
205
272
|
|
|
206
273
|
```js
|
|
274
|
+
import { DB } from 'tspace-mysql'
|
|
207
275
|
|
|
208
276
|
await new DB().from('users').find(1)
|
|
209
277
|
// SELECT * FROM `users` WHERE `users`.`id` = '1' LIMIT 1;
|
|
@@ -237,6 +305,10 @@ const users = await new DB("users").findMany(); // Array-object of users
|
|
|
237
305
|
|
|
238
306
|
const users = await new DB("users").get(); // Array-object of users
|
|
239
307
|
|
|
308
|
+
const users = await new DB("users").getGroupBy('name') // Map
|
|
309
|
+
|
|
310
|
+
const users = await new DB("users").findGroupBy('name') // Map
|
|
311
|
+
|
|
240
312
|
const users = await new DB("users").toArray(); // Array of users
|
|
241
313
|
|
|
242
314
|
const users = await new DB("users").toJSON(); // JSON of users
|
|
@@ -499,13 +571,13 @@ const users = await new DB("users")
|
|
|
499
571
|
### Where Object Clauses
|
|
500
572
|
|
|
501
573
|
```js
|
|
502
|
-
import {
|
|
574
|
+
import { OP } from 'tspace-mysql'
|
|
503
575
|
|
|
504
576
|
const whereObject = await new DB("users")
|
|
505
577
|
.whereObject({
|
|
506
|
-
id :
|
|
507
|
-
username :
|
|
508
|
-
name :
|
|
578
|
+
id : OP.notEq(1),
|
|
579
|
+
username : OP.in(['user1','user2']),
|
|
580
|
+
name : OP.like('%value%')
|
|
509
581
|
})
|
|
510
582
|
.findMany();
|
|
511
583
|
|
|
@@ -644,6 +716,19 @@ const users = await new DB("users")
|
|
|
644
716
|
// SELECT * FROM `users` WHERE `users`.`id` = '1';
|
|
645
717
|
```
|
|
646
718
|
|
|
719
|
+
## GetGroupBy
|
|
720
|
+
|
|
721
|
+
```js
|
|
722
|
+
const data = await new DB("posts").getGroupBy('user_id')
|
|
723
|
+
|
|
724
|
+
// return new Map()
|
|
725
|
+
// find posts by user id
|
|
726
|
+
const userHasPosts = data.get(1)
|
|
727
|
+
|
|
728
|
+
console.log(userHasPosts)
|
|
729
|
+
|
|
730
|
+
```
|
|
731
|
+
|
|
647
732
|
## Paginating
|
|
648
733
|
|
|
649
734
|
```js
|
|
@@ -981,8 +1066,8 @@ const user = await new User()
|
|
|
981
1066
|
## More Methods
|
|
982
1067
|
|
|
983
1068
|
```js
|
|
984
|
-
where(column ,
|
|
985
|
-
whereSensitive(column ,
|
|
1069
|
+
where(column , OP , value)
|
|
1070
|
+
whereSensitive(column , OP , value)
|
|
986
1071
|
whereId(id)
|
|
987
1072
|
whereUser(userId)
|
|
988
1073
|
whereEmail(value)
|
|
@@ -992,12 +1077,12 @@ whereNull(column)
|
|
|
992
1077
|
whereNotNull(column)
|
|
993
1078
|
whereBetween (column , [value1 , value2])
|
|
994
1079
|
whereQuery(callback)
|
|
995
|
-
whereJson(column, { targetKey, value ,
|
|
1080
|
+
whereJson(column, { targetKey, value , OP })
|
|
996
1081
|
whereRaw(sql)
|
|
997
1082
|
whereExists(sql)
|
|
998
1083
|
whereSubQuery(colmn , rawSQL)
|
|
999
1084
|
whereNotSubQuery(colmn , rawSQL)
|
|
1000
|
-
orWhere(column ,
|
|
1085
|
+
orWhere(column , OP , value)
|
|
1001
1086
|
orWhereRaw(sql)
|
|
1002
1087
|
orWhereIn(column , [])
|
|
1003
1088
|
orWhereSubQuery(colmn , rawSQL)
|
|
@@ -2254,8 +2339,11 @@ Let's illustrate this with an example of a cache:
|
|
|
2254
2339
|
// set cache in file config .env , .env.development ... etc
|
|
2255
2340
|
DB_CACHE = memory // by default
|
|
2256
2341
|
|
|
2342
|
+
// for db
|
|
2343
|
+
DB_CACHE = db
|
|
2344
|
+
|
|
2257
2345
|
// for redis
|
|
2258
|
-
|
|
2346
|
+
DB_CACHE = redis://username:password@server:6379
|
|
2259
2347
|
|
|
2260
2348
|
const users = await new User()
|
|
2261
2349
|
.cache({
|
|
@@ -2368,9 +2456,9 @@ const schema = {
|
|
|
2368
2456
|
uuid: Blueprint.varchar(50).null().index(),
|
|
2369
2457
|
name: Blueprint.varchar(191).notNull(),
|
|
2370
2458
|
email: Blueprint.varchar(191).notNull(),
|
|
2371
|
-
createdAt: Blueprint.timestamp().null()
|
|
2372
|
-
updatedAt: Blueprint.timestamp().null()
|
|
2373
|
-
deletedAt: Blueprint.timestamp().null()
|
|
2459
|
+
createdAt: Blueprint.timestamp().null(),
|
|
2460
|
+
updatedAt: Blueprint.timestamp().null(),
|
|
2461
|
+
deletedAt: Blueprint.timestamp().null()
|
|
2374
2462
|
}
|
|
2375
2463
|
|
|
2376
2464
|
|
|
@@ -2967,26 +3055,53 @@ It provides methods for querying, inserting, updating, and deleting records in t
|
|
|
2967
3055
|
```
|
|
2968
3056
|
### Repository Select Statements
|
|
2969
3057
|
```js
|
|
2970
|
-
import { Repository , TRepository ,
|
|
3058
|
+
import { Repository , TRepository , OP } from 'tspace-mysql'
|
|
2971
3059
|
import { User } from '../Models/User'
|
|
2972
3060
|
|
|
2973
|
-
const userRepository = Repository
|
|
3061
|
+
const userRepository = Repository(User)
|
|
2974
3062
|
const needPhone = true
|
|
2975
3063
|
const user = await userRepository.findOne({
|
|
2976
|
-
select :
|
|
3064
|
+
select : {
|
|
3065
|
+
id : true,
|
|
3066
|
+
name : true,
|
|
3067
|
+
username : true,
|
|
3068
|
+
phone : {
|
|
3069
|
+
id : true,
|
|
3070
|
+
name : true,
|
|
3071
|
+
user_id : true,
|
|
3072
|
+
}
|
|
3073
|
+
},
|
|
2977
3074
|
where : {
|
|
2978
3075
|
id: 1
|
|
2979
3076
|
},
|
|
2980
3077
|
when : {
|
|
2981
|
-
condition :
|
|
2982
|
-
|
|
2983
|
-
relations :
|
|
3078
|
+
condition : needPhone,
|
|
3079
|
+
query: () => ({
|
|
3080
|
+
relations : {
|
|
3081
|
+
phone : true
|
|
3082
|
+
/**
|
|
3083
|
+
You can also specify the phone with any methods of the repository
|
|
3084
|
+
phone : {
|
|
3085
|
+
where : {
|
|
3086
|
+
id : 41
|
|
3087
|
+
},
|
|
3088
|
+
select : {
|
|
3089
|
+
id : true,
|
|
3090
|
+
user_id : true
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
*/
|
|
3094
|
+
}
|
|
2984
3095
|
})
|
|
2985
3096
|
}
|
|
2986
3097
|
})
|
|
2987
3098
|
|
|
2988
3099
|
const users = await userRepository.findMany({
|
|
2989
|
-
select :
|
|
3100
|
+
select : {
|
|
3101
|
+
id : true,
|
|
3102
|
+
name : true,
|
|
3103
|
+
username : true,
|
|
3104
|
+
},
|
|
2990
3105
|
limit : 3,
|
|
2991
3106
|
orderBy : {
|
|
2992
3107
|
id : 'ASC',
|
|
@@ -2994,21 +3109,28 @@ const users = await userRepository.findMany({
|
|
|
2994
3109
|
}
|
|
2995
3110
|
groupBy : ['id'],
|
|
2996
3111
|
where : {
|
|
2997
|
-
id:
|
|
3112
|
+
id: OP.in([1,2,3])
|
|
2998
3113
|
}
|
|
2999
3114
|
})
|
|
3000
3115
|
|
|
3001
3116
|
const userPaginate = await userRepository.pagination({
|
|
3002
|
-
select :
|
|
3117
|
+
select : {
|
|
3118
|
+
id : true,
|
|
3119
|
+
name : true,
|
|
3120
|
+
username : true,
|
|
3121
|
+
},
|
|
3003
3122
|
page : 1,
|
|
3004
3123
|
limit : 3,
|
|
3005
3124
|
where : {
|
|
3006
|
-
id:
|
|
3125
|
+
id: OP.in([1,2,3])
|
|
3007
3126
|
}
|
|
3008
3127
|
})
|
|
3009
3128
|
|
|
3010
3129
|
const findFullName = await userRepository.findOne({
|
|
3011
|
-
select :
|
|
3130
|
+
select : {
|
|
3131
|
+
name : true,
|
|
3132
|
+
[`${DB.raw('CONCAT(firstName," ",lastName) as fullName')}`]: true
|
|
3133
|
+
}
|
|
3012
3134
|
whereRaw : [
|
|
3013
3135
|
`CONCAT(firstName," ",lastName) LIKE '%${search}%'`
|
|
3014
3136
|
]
|
|
@@ -3017,7 +3139,7 @@ const findFullName = await userRepository.findOne({
|
|
|
3017
3139
|
### Repository Insert Statements
|
|
3018
3140
|
```js
|
|
3019
3141
|
|
|
3020
|
-
const userRepository = Repository
|
|
3142
|
+
const userRepository = Repository(User)
|
|
3021
3143
|
|
|
3022
3144
|
const created = await userRepository.create({
|
|
3023
3145
|
data : {
|
|
@@ -3069,7 +3191,7 @@ const createdOrSelected = await userRepository.createOrSelect({
|
|
|
3069
3191
|
### Repository Update Statements
|
|
3070
3192
|
```js
|
|
3071
3193
|
|
|
3072
|
-
const userRepository = Repository
|
|
3194
|
+
const userRepository = Repository(User)
|
|
3073
3195
|
|
|
3074
3196
|
const updated = await userRepository.update({
|
|
3075
3197
|
data : {
|
|
@@ -3085,7 +3207,7 @@ const updated = await userRepository.update({
|
|
|
3085
3207
|
### Repository Delete Statements
|
|
3086
3208
|
```js
|
|
3087
3209
|
|
|
3088
|
-
const userRepository = Repository
|
|
3210
|
+
const userRepository = Repository(User)
|
|
3089
3211
|
|
|
3090
3212
|
const deleted = await userRepository.delete({
|
|
3091
3213
|
where : {
|
|
@@ -3100,7 +3222,7 @@ const deleted = await userRepository.delete({
|
|
|
3100
3222
|
```js
|
|
3101
3223
|
import { DB , Repository } from 'tspace-mysql'
|
|
3102
3224
|
import { User } from '../Models/User'
|
|
3103
|
-
const userRepository = Repository
|
|
3225
|
+
const userRepository = Repository(User)
|
|
3104
3226
|
|
|
3105
3227
|
const transaction = await DB.beginTransaction()
|
|
3106
3228
|
|
|
@@ -3137,11 +3259,11 @@ try {
|
|
|
3137
3259
|
|
|
3138
3260
|
### Repository Relations
|
|
3139
3261
|
```js
|
|
3140
|
-
import { Repository , TRepository ,
|
|
3262
|
+
import { Repository , TRepository , OP } from 'tspace-mysql'
|
|
3141
3263
|
import { User } from '../Models/User'
|
|
3142
3264
|
import { Phone } from '../Models/Phone'
|
|
3143
3265
|
|
|
3144
|
-
const userRepository = Repository
|
|
3266
|
+
const userRepository = Repository(User)
|
|
3145
3267
|
|
|
3146
3268
|
const userHasPhones = await userRepository.findOne({
|
|
3147
3269
|
select : ['*'],
|
|
@@ -3158,7 +3280,7 @@ const userHasPhones = await userRepository.findOne({
|
|
|
3158
3280
|
}
|
|
3159
3281
|
})
|
|
3160
3282
|
|
|
3161
|
-
const phoneRepository = Repository
|
|
3283
|
+
const phoneRepository = Repository(Phone)
|
|
3162
3284
|
|
|
3163
3285
|
const phoneBelongUser = await phoneRepository.findOne({
|
|
3164
3286
|
select : ['*'],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { EventEmitter } from 'events';
|
|
2
3
|
import { loadOptionsEnvironment } from '../options';
|
|
3
4
|
import type { TConnection, TOptions } from '../types';
|
|
@@ -15,7 +16,7 @@ export declare class PoolConnection extends EventEmitter {
|
|
|
15
16
|
* @property {Function} Connection.query
|
|
16
17
|
* @property {Function} Connection.connection
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
connected(): TConnection;
|
|
19
20
|
private _detectEventQuery;
|
|
20
21
|
private _detectQueryType;
|
|
21
22
|
private _defaultOptions;
|
|
@@ -31,15 +31,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
35
|
exports.Pool = exports.loadOptionsEnvironment = exports.PoolConnection = void 0;
|
|
39
|
-
const fs_1 = __importDefault(require("fs"));
|
|
40
|
-
const path_1 = __importDefault(require("path"));
|
|
41
36
|
const events_1 = require("events");
|
|
42
37
|
const mysql2_1 = require("mysql2");
|
|
38
|
+
const tools_1 = require("../tools");
|
|
43
39
|
const options_1 = __importStar(require("../options"));
|
|
44
40
|
Object.defineProperty(exports, "loadOptionsEnvironment", { enumerable: true, get: function () { return options_1.loadOptionsEnvironment; } });
|
|
45
41
|
class PoolConnection extends events_1.EventEmitter {
|
|
@@ -61,7 +57,7 @@ class PoolConnection extends events_1.EventEmitter {
|
|
|
61
57
|
* @property {Function} Connection.query
|
|
62
58
|
* @property {Function} Connection.connection
|
|
63
59
|
*/
|
|
64
|
-
|
|
60
|
+
connected() {
|
|
65
61
|
const pool = (0, mysql2_1.createPool)(Object.fromEntries(this.OPTIONS));
|
|
66
62
|
/**
|
|
67
63
|
* After the server is listening, verify that the pool has successfully connected to the database.
|
|
@@ -116,7 +112,7 @@ class PoolConnection extends events_1.EventEmitter {
|
|
|
116
112
|
};
|
|
117
113
|
const startTransaction = () => __awaiter(this, void 0, void 0, function* () {
|
|
118
114
|
// don't use await as it blocks all connection pools. and ignore the .bind(...) method.
|
|
119
|
-
query('START TRANSACTION')
|
|
115
|
+
yield query('START TRANSACTION')
|
|
120
116
|
.catch(err => reject(err));
|
|
121
117
|
return;
|
|
122
118
|
});
|
|
@@ -218,11 +214,11 @@ class PoolConnection extends events_1.EventEmitter {
|
|
|
218
214
|
* charset =
|
|
219
215
|
* }
|
|
220
216
|
*/
|
|
221
|
-
const dbOptionsPath =
|
|
222
|
-
const dbOptionsExists =
|
|
217
|
+
const dbOptionsPath = tools_1.Tool.path.join(tools_1.Tool.path.resolve(), 'db.tspace');
|
|
218
|
+
const dbOptionsExists = tools_1.Tool.fs.existsSync(dbOptionsPath);
|
|
223
219
|
if (!dbOptionsExists)
|
|
224
220
|
return this._defaultOptions();
|
|
225
|
-
const dbOptions =
|
|
221
|
+
const dbOptions = tools_1.Tool.fs.readFileSync(dbOptionsPath, 'utf8');
|
|
226
222
|
const options = this._convertStringToObject(dbOptions);
|
|
227
223
|
if (options == null)
|
|
228
224
|
return this._defaultOptions();
|
|
@@ -352,7 +348,7 @@ exports.PoolConnection = PoolConnection;
|
|
|
352
348
|
* @property {Function} Connection.query
|
|
353
349
|
* @property {Function} Connection.connection
|
|
354
350
|
*/
|
|
355
|
-
const pool = new PoolConnection().
|
|
351
|
+
const pool = new PoolConnection().connected();
|
|
356
352
|
exports.Pool = pool;
|
|
357
353
|
exports.default = pool;
|
|
358
354
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/connection/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/connection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAqC;AACrC,mCAKe;AACf,oCAA+B;AAC/B,sDAEmB;AAyXV,uGA1XL,gCAAsB,OA0XK;AAjX/B,MAAa,cAAe,SAAQ,qBAAY;IAI5C;;;OAGG;IACH,YAAY,OAAmB;QAC3B,KAAK,EAAE,CAAA;QAPH,YAAO,GAAG,IAAI,CAAC,YAAY,EAAE,CAAA;QAQjC,IAAG,OAAO,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAClB,MAAM,CAAC,OAAO,iCACP,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAChC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EACxC,CACL,CAAA;QACL,CAAC;IACL,CAAC;IACD;;;;;;OAMG;IACI,SAAS;QAEZ,MAAM,IAAI,GAAW,IAAA,mBAAU,EAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEjE;;;;WAIG;QACH,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAEzB,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE;YAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;QACpC,CAAC,CAAC,CAAA;QAEF,OAAO;YACH,EAAE,EAAG,CAAC,KAAkB,EAAG,IAAI,EAAE,E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O,GAAG,uFAAuF,QAAQ,wBAAwB,GAAG,UAAU,CAAA;QAEpJ,OAAO,OAAO,CAAA;IAClB,CAAC;CACJ;AArWD,wCAqWC;AAED;;;;;;;GAOG;AACH,MAAM,IAAI,GAAG,IAAI,cAAc,EAAE,CAAC,SAAS,EAAE,CAAA;AAG5B,oBAAI;AAErB,kBAAe,IAAI,CAAA"}
|
|
@@ -58,8 +58,8 @@ declare abstract class AbstractBuilder {
|
|
|
58
58
|
foreignKey: string;
|
|
59
59
|
sql: string;
|
|
60
60
|
}): this;
|
|
61
|
-
abstract orderBy(column: string, order: 'ASC' | 'DESC'): this;
|
|
62
|
-
abstract orderByRaw(column: string, order:
|
|
61
|
+
abstract orderBy(column: string, order: 'ASC' | 'asc' | 'DESC' | 'desc'): this;
|
|
62
|
+
abstract orderByRaw(column: string, order: 'ASC' | 'asc' | 'DESC' | 'desc'): this;
|
|
63
63
|
abstract latest(...columns: string[]): this;
|
|
64
64
|
abstract latestRaw(...columns: string[]): this;
|
|
65
65
|
abstract oldest(...columns: string[]): this;
|
|
@@ -104,8 +104,8 @@ declare abstract class AbstractBuilder {
|
|
|
104
104
|
abstract get(): Promise<any[]>;
|
|
105
105
|
abstract findOne(): Promise<Record<string, any> | null>;
|
|
106
106
|
abstract findMany(): Promise<any[]>;
|
|
107
|
-
abstract getGroupBy(column: string): Promise<
|
|
108
|
-
abstract findGroupBy(column: string): Promise<
|
|
107
|
+
abstract getGroupBy(column: string): Promise<Map<string | number, any[]>>;
|
|
108
|
+
abstract findGroupBy(column: string): Promise<Map<string | number, any[]>>;
|
|
109
109
|
abstract toArray(column: string): Promise<any[]>;
|
|
110
110
|
abstract toJSON(): Promise<string>;
|
|
111
111
|
abstract toSQL(): string;
|
|
@@ -84,7 +84,7 @@ declare class Builder extends AbstractBuilder {
|
|
|
84
84
|
* @param {string} alias as name of the column
|
|
85
85
|
* @returns {this} this
|
|
86
86
|
*/
|
|
87
|
-
selectObject(object: Record<string, `${string}.${string}`>, alias: string): this;
|
|
87
|
+
selectObject(object: Record<string, string | `${string}.${string}`>, alias: string): this;
|
|
88
88
|
/**
|
|
89
89
|
* The 'selectObject' method is used to specify which columns you want to retrieve from a database table.
|
|
90
90
|
*
|
|
@@ -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
|
*
|
|
@@ -1326,22 +1326,33 @@ declare class Builder extends AbstractBuilder {
|
|
|
1326
1326
|
*
|
|
1327
1327
|
* It retrieves multiple records from a database table based on the criteria specified in the query.
|
|
1328
1328
|
*
|
|
1329
|
-
* It returns record
|
|
1329
|
+
* It returns record to new Map
|
|
1330
1330
|
* @param {string} column
|
|
1331
|
-
* @
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
/**
|
|
1335
|
-
*
|
|
1336
|
-
* The 'findGroupBy' method is used to execute a database query and retrieve the result set that matches the query conditions.
|
|
1337
|
-
*
|
|
1338
|
-
* It retrieves multiple records from a database table based on the criteria specified in the query.
|
|
1331
|
+
* @example
|
|
1332
|
+
* const results = await new DB('posts')
|
|
1333
|
+
* .getGroupBy('user_id')
|
|
1339
1334
|
*
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1335
|
+
* // you can find with user id in the results
|
|
1336
|
+
* const postsByUserId1 = results.get(1)
|
|
1342
1337
|
* @returns {promise<Array>}
|
|
1343
1338
|
*/
|
|
1344
|
-
|
|
1339
|
+
getGroupBy(column: string): Promise<Map<string | number, any[]>>;
|
|
1340
|
+
/**
|
|
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
|
+
findGroupBy(column: string): Promise<Map<string | number, any[]>>;
|
|
1345
1356
|
/**
|
|
1346
1357
|
* The 'save' method is used to persist a new 'Model' or new 'DB' instance or update an existing model instance in the database.
|
|
1347
1358
|
*
|