@midwayjs/sequelize 3.3.4 → 3.4.0-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/CHANGELOG.md +389 -0
- package/README.md +4 -69
- package/dist/configuration.d.ts +7 -3
- package/dist/configuration.js +29 -11
- package/dist/dataSourceManager.d.ts +12 -0
- package/dist/dataSourceManager.js +83 -0
- package/dist/decorator.d.ts +11 -0
- package/dist/{core/baseTable.js → decorator.js} +14 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.js +20 -3
- package/dist/interface.d.ts +6 -0
- package/dist/interface.js +3 -0
- package/index.d.ts +2 -5
- package/package.json +8 -8
- package/LICENSE +0 -21
- package/dist/config/config.default.d.ts +0 -8
- package/dist/config/config.default.js +0 -12
- package/dist/core/baseTable.d.ts +0 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [3.3.6](https://github.com/midwayjs/midway/compare/v3.3.5...v3.3.6) (2022-05-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.3.5](https://github.com/midwayjs/midway/compare/v3.3.4...v3.3.5) (2022-04-27)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [3.3.4](https://github.com/midwayjs/midway/compare/v3.3.3...v3.3.4) (2022-04-21)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [3.3.2](https://github.com/midwayjs/midway/compare/v3.3.1...v3.3.2) (2022-04-13)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [3.3.1](https://github.com/midwayjs/midway/compare/v3.3.0...v3.3.1) (2022-04-11)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# [3.3.0](https://github.com/midwayjs/midway/compare/v3.2.2...v3.3.0) (2022-04-07)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## [3.2.2](https://github.com/midwayjs/midway/compare/v3.2.1...v3.2.2) (2022-03-30)
|
|
55
|
+
|
|
56
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## [3.2.1](https://github.com/midwayjs/midway/compare/v3.2.0...v3.2.1) (2022-03-27)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Bug Fixes
|
|
66
|
+
|
|
67
|
+
* swagger ui replace json path ([#1860](https://github.com/midwayjs/midway/issues/1860)) ([0f3728d](https://github.com/midwayjs/midway/commit/0f3728daccba12923f23f5b498c7dda13ced36d7))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# [3.2.0](https://github.com/midwayjs/midway/compare/v3.1.6...v3.2.0) (2022-03-25)
|
|
74
|
+
|
|
75
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## [3.1.6](https://github.com/midwayjs/midway/compare/v3.1.5...v3.1.6) (2022-03-21)
|
|
82
|
+
|
|
83
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## [3.1.5](https://github.com/midwayjs/midway/compare/v3.1.4...v3.1.5) (2022-03-18)
|
|
90
|
+
|
|
91
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## [3.1.2](https://github.com/midwayjs/midway/compare/v3.1.1...v3.1.2) (2022-03-15)
|
|
98
|
+
|
|
99
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## [3.1.1](https://github.com/midwayjs/midway/compare/v3.1.0...v3.1.1) (2022-03-09)
|
|
106
|
+
|
|
107
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# [3.1.0](https://github.com/midwayjs/midway/compare/v3.0.13...v3.1.0) (2022-03-07)
|
|
114
|
+
|
|
115
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
## [3.0.13](https://github.com/midwayjs/midway/compare/v3.0.12...v3.0.13) (2022-03-01)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Bug Fixes
|
|
125
|
+
|
|
126
|
+
* **deps:** update dependency sequelize to ~6.17.0 ([#1750](https://github.com/midwayjs/midway/issues/1750)) ([5176df9](https://github.com/midwayjs/midway/commit/5176df979528fd41e648771847c32236f19e2baf))
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## [3.0.11](https://github.com/midwayjs/midway/compare/v3.0.10...v3.0.11) (2022-02-25)
|
|
133
|
+
|
|
134
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
## [3.0.10](https://github.com/midwayjs/midway/compare/v3.0.9...v3.0.10) (2022-02-24)
|
|
141
|
+
|
|
142
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
## [3.0.9](https://github.com/midwayjs/midway/compare/v3.0.8...v3.0.9) (2022-02-21)
|
|
149
|
+
|
|
150
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
## [3.0.8](https://github.com/midwayjs/midway/compare/v3.0.7...v3.0.8) (2022-02-19)
|
|
157
|
+
|
|
158
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
## [3.0.7](https://github.com/midwayjs/midway/compare/v3.0.6...v3.0.7) (2022-02-17)
|
|
165
|
+
|
|
166
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## [3.0.6](https://github.com/midwayjs/midway/compare/v3.0.5...v3.0.6) (2022-02-13)
|
|
173
|
+
|
|
174
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
## [3.0.5](https://github.com/midwayjs/midway/compare/v3.0.4...v3.0.5) (2022-02-10)
|
|
181
|
+
|
|
182
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
## [3.0.4](https://github.com/midwayjs/midway/compare/v3.0.3...v3.0.4) (2022-02-09)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
### Bug Fixes
|
|
192
|
+
|
|
193
|
+
* **deps:** update dependency sequelize to ~6.15.0 ([#1644](https://github.com/midwayjs/midway/issues/1644)) ([eb241f2](https://github.com/midwayjs/midway/commit/eb241f2a3f7aea5c70d28ae1dca265ddf2a78b5a))
|
|
194
|
+
* **deps:** update dependency sequelize to ~6.16.0 ([#1677](https://github.com/midwayjs/midway/issues/1677)) ([bf84760](https://github.com/midwayjs/midway/commit/bf8476078801eb34551df242b56345cd2621c6ff))
|
|
195
|
+
* supertest typings and createFunctionApp ([#1642](https://github.com/midwayjs/midway/issues/1642)) ([484f4f4](https://github.com/midwayjs/midway/commit/484f4f41b3b9e889d4d285f4871a0b37fa51e73f))
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## [3.0.3](https://github.com/midwayjs/midway/compare/v3.0.2...v3.0.3) (2022-01-28)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
### Bug Fixes
|
|
205
|
+
|
|
206
|
+
* **deps:** update dependency sequelize to ~6.14.0 ([#1617](https://github.com/midwayjs/midway/issues/1617)) ([f29fc0f](https://github.com/midwayjs/midway/commit/f29fc0fb166cafa09e8cfd7e801417ea7731d437))
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
## [3.0.2](https://github.com/midwayjs/midway/compare/v3.0.1...v3.0.2) (2022-01-24)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
### Bug Fixes
|
|
216
|
+
|
|
217
|
+
* singleton invoke request scope not valid ([#1622](https://github.com/midwayjs/midway/issues/1622)) ([f97c063](https://github.com/midwayjs/midway/commit/f97c0632107b47cf357d17774a4e4bb5233bba57))
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
## [3.0.1](https://github.com/midwayjs/midway/compare/v3.0.0...v3.0.1) (2022-01-24)
|
|
224
|
+
|
|
225
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
# [3.0.0](https://github.com/midwayjs/midway/compare/v3.0.0-beta.17...v3.0.0) (2022-01-20)
|
|
232
|
+
|
|
233
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
# [3.0.0-beta.17](https://github.com/midwayjs/midway/compare/v3.0.0-beta.16...v3.0.0-beta.17) (2022-01-18)
|
|
240
|
+
|
|
241
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
# [3.0.0-beta.16](https://github.com/midwayjs/midway/compare/v3.0.0-beta.15...v3.0.0-beta.16) (2022-01-11)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
### Bug Fixes
|
|
251
|
+
|
|
252
|
+
* **deps:** update dependency sequelize to ~6.13.0 ([#1554](https://github.com/midwayjs/midway/issues/1554)) ([0a82a2c](https://github.com/midwayjs/midway/commit/0a82a2c698f9b85debf3d09850fb9d350b27bba7))
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
# [3.0.0-beta.15](https://github.com/midwayjs/midway/compare/v3.0.0-beta.14...v3.0.0-beta.15) (2022-01-07)
|
|
259
|
+
|
|
260
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
# [3.0.0-beta.14](https://github.com/midwayjs/midway/compare/v3.0.0-beta.13...v3.0.0-beta.14) (2022-01-04)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
### Bug Fixes
|
|
270
|
+
|
|
271
|
+
* **deps:** update dependency sequelize to ~6.12.0 ([#1509](https://github.com/midwayjs/midway/issues/1509)) ([6f96bf7](https://github.com/midwayjs/midway/commit/6f96bf745761c849c94a8977436dc2955f3d9a3c))
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
# [3.0.0-beta.13](https://github.com/midwayjs/midway/compare/v3.0.0-beta.12...v3.0.0-beta.13) (2021-12-30)
|
|
278
|
+
|
|
279
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
# [3.0.0-beta.12](https://github.com/midwayjs/midway/compare/v3.0.0-beta.11...v3.0.0-beta.12) (2021-12-28)
|
|
286
|
+
|
|
287
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
# [3.0.0-beta.11](https://github.com/midwayjs/midway/compare/v3.0.0-beta.10...v3.0.0-beta.11) (2021-12-21)
|
|
294
|
+
|
|
295
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
# [3.0.0-beta.10](https://github.com/midwayjs/midway/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2021-12-20)
|
|
302
|
+
|
|
303
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
# [3.0.0-beta.9](https://github.com/midwayjs/midway/compare/v3.0.0-beta.8...v3.0.0-beta.9) (2021-12-09)
|
|
310
|
+
|
|
311
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
# [3.0.0-beta.8](https://github.com/midwayjs/midway/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2021-12-08)
|
|
318
|
+
|
|
319
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
# [3.0.0-beta.7](https://github.com/midwayjs/midway/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-12-03)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
### Bug Fixes
|
|
329
|
+
|
|
330
|
+
* add app.keys ([#1395](https://github.com/midwayjs/midway/issues/1395)) ([c44afc6](https://github.com/midwayjs/midway/commit/c44afc6cc6764a959d1fa7ae04d60099282d156a))
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
# [3.0.0-beta.6](https://github.com/midwayjs/midway/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-11-26)
|
|
337
|
+
|
|
338
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
# [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
|
|
345
|
+
|
|
346
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
# [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
|
|
353
|
+
|
|
354
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
# [3.0.0-beta.3](https://github.com/midwayjs/midway/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2021-11-18)
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
### Features
|
|
364
|
+
|
|
365
|
+
* add component and framework config definition ([#1367](https://github.com/midwayjs/midway/issues/1367)) ([b2fe615](https://github.com/midwayjs/midway/commit/b2fe6157f99659471ff1333eca0b86bb889f61a3))
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
# [3.0.0-beta.2](https://github.com/midwayjs/midway/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2021-11-16)
|
|
372
|
+
|
|
373
|
+
**Note:** Version bump only for package @midwayjs/sequelize
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
# [3.0.0-beta.1](https://github.com/midwayjs/midway/compare/v2.12.4...v3.0.0-beta.1) (2021-11-14)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
### Bug Fixes
|
|
383
|
+
|
|
384
|
+
* static prefix ([#1321](https://github.com/midwayjs/midway/issues/1321)) ([31fe961](https://github.com/midwayjs/midway/commit/31fe961931fed7656a144b1682ee4c4bb25fdff5))
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
### Features
|
|
388
|
+
|
|
389
|
+
* add sequelize component ([#1283](https://github.com/midwayjs/midway/issues/1283)) ([9ad91d1](https://github.com/midwayjs/midway/commit/9ad91d1e3ef3cf4cd799a1f8ef3d57b7efae60cf))
|
package/README.md
CHANGED
|
@@ -1,74 +1,9 @@
|
|
|
1
1
|
# midway sequelize component
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
this is a sub package for midway.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Document: [https://midwayjs.org](https://midwayjs.org)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
@Configuration({
|
|
9
|
-
imports: [
|
|
10
|
-
'@midwayjs/sequelize',
|
|
11
|
-
],
|
|
12
|
-
importConfigs: [
|
|
13
|
-
'./config'
|
|
14
|
-
]
|
|
15
|
-
})
|
|
16
|
-
export class ContainerConfiguration {
|
|
17
|
-
}
|
|
7
|
+
## License
|
|
18
8
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## Configuration
|
|
22
|
-
|
|
23
|
-
in config files
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
export const sequelize = {
|
|
28
|
-
options: {
|
|
29
|
-
database: 'test4',
|
|
30
|
-
username: 'root',
|
|
31
|
-
password: '123456',
|
|
32
|
-
host: '127.0.0.1',
|
|
33
|
-
port: 3306,
|
|
34
|
-
encrypt: false,
|
|
35
|
-
logging: console.log
|
|
36
|
-
},
|
|
37
|
-
sync: false
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Define EntityModel
|
|
42
|
-
|
|
43
|
-
```ts
|
|
44
|
-
import { Column, Model } from "sequelize-typescript";
|
|
45
|
-
import { BaseTable } from "@midwayjs/sequelize";
|
|
46
|
-
|
|
47
|
-
@BaseTable
|
|
48
|
-
export default class UserModel extends Model{
|
|
49
|
-
@Column({
|
|
50
|
-
comment: '名字'
|
|
51
|
-
})
|
|
52
|
-
name: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## Use Model
|
|
59
|
-
|
|
60
|
-
in code files
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
import { UserModel } from './model/user';
|
|
64
|
-
|
|
65
|
-
@Provide()
|
|
66
|
-
export class IndexHandler {
|
|
67
|
-
|
|
68
|
-
@Func('index.handler')
|
|
69
|
-
async handler() {
|
|
70
|
-
const users = await this.UserModel.findAll();
|
|
71
|
-
return users;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
9
|
+
[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
|
package/dist/configuration.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SequelizeDataSourceManager } from './dataSourceManager';
|
|
2
|
+
import { IMidwayContainer, MidwayDecoratorService } from '@midwayjs/core';
|
|
2
3
|
export declare class SequelizeConfiguration {
|
|
3
|
-
instance: Sequelize;
|
|
4
4
|
sequelizeConfig: any;
|
|
5
|
-
|
|
5
|
+
decoratorService: MidwayDecoratorService;
|
|
6
|
+
dataSourceManager: SequelizeDataSourceManager;
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
onReady(container: IMidwayContainer): Promise<void>;
|
|
9
|
+
onStop(): Promise<void>;
|
|
6
10
|
}
|
|
7
11
|
//# sourceMappingURL=configuration.d.ts.map
|
package/dist/configuration.js
CHANGED
|
@@ -11,17 +11,23 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SequelizeConfiguration = void 0;
|
|
13
13
|
const decorator_1 = require("@midwayjs/decorator");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const dataSourceManager_1 = require("./dataSourceManager");
|
|
15
|
+
const core_1 = require("@midwayjs/core");
|
|
16
|
+
const decorator_2 = require("./decorator");
|
|
16
17
|
let SequelizeConfiguration = class SequelizeConfiguration {
|
|
17
|
-
async
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
async init() {
|
|
19
|
+
this.decoratorService.registerPropertyHandler(decorator_2.ENTITY_MODEL_KEY, (propertyName, meta) => {
|
|
20
|
+
return this.dataSourceManager
|
|
21
|
+
.getDataSource(meta.connectionName)
|
|
22
|
+
.getRepository(meta.modelKey);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async onReady(container) {
|
|
26
|
+
this.dataSourceManager = await container.getAsync(dataSourceManager_1.SequelizeDataSourceManager);
|
|
27
|
+
}
|
|
28
|
+
async onStop() {
|
|
29
|
+
if (this.dataSourceManager) {
|
|
30
|
+
await this.dataSourceManager.stop();
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
};
|
|
@@ -29,12 +35,24 @@ __decorate([
|
|
|
29
35
|
(0, decorator_1.Config)('sequelize'),
|
|
30
36
|
__metadata("design:type", Object)
|
|
31
37
|
], SequelizeConfiguration.prototype, "sequelizeConfig", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, decorator_1.Inject)(),
|
|
40
|
+
__metadata("design:type", core_1.MidwayDecoratorService)
|
|
41
|
+
], SequelizeConfiguration.prototype, "decoratorService", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, decorator_1.Init)(),
|
|
44
|
+
__metadata("design:type", Function),
|
|
45
|
+
__metadata("design:paramtypes", []),
|
|
46
|
+
__metadata("design:returntype", Promise)
|
|
47
|
+
], SequelizeConfiguration.prototype, "init", null);
|
|
32
48
|
SequelizeConfiguration = __decorate([
|
|
33
49
|
(0, decorator_1.Configuration)({
|
|
34
50
|
namespace: 'sequelize',
|
|
35
51
|
importConfigs: [
|
|
36
52
|
{
|
|
37
|
-
default:
|
|
53
|
+
default: {
|
|
54
|
+
sequelize: {},
|
|
55
|
+
},
|
|
38
56
|
},
|
|
39
57
|
],
|
|
40
58
|
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DataSourceManager, ILogger } from '@midwayjs/core';
|
|
2
|
+
import { Sequelize } from 'sequelize-typescript';
|
|
3
|
+
export declare class SequelizeDataSourceManager extends DataSourceManager<Sequelize> {
|
|
4
|
+
sequelizeConfig: any;
|
|
5
|
+
coreLogger: ILogger;
|
|
6
|
+
init(): Promise<void>;
|
|
7
|
+
getName(): string;
|
|
8
|
+
protected createDataSource(config: any, dataSourceName: string): Promise<Sequelize>;
|
|
9
|
+
protected checkConnected(dataSource: Sequelize): Promise<boolean>;
|
|
10
|
+
protected destroyDataSource(dataSource: Sequelize): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=dataSourceManager.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SequelizeDataSourceManager = void 0;
|
|
13
|
+
const decorator_1 = require("@midwayjs/decorator");
|
|
14
|
+
const core_1 = require("@midwayjs/core");
|
|
15
|
+
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
16
|
+
let SequelizeDataSourceManager = class SequelizeDataSourceManager extends core_1.DataSourceManager {
|
|
17
|
+
async init() {
|
|
18
|
+
if (this.sequelizeConfig.options) {
|
|
19
|
+
this.coreLogger.warn('[midway:sequelize] sequelize.options is deprecated, please use new config format.');
|
|
20
|
+
this.sequelizeConfig.options.sync = this.sequelizeConfig.sync || false;
|
|
21
|
+
// legacy config
|
|
22
|
+
this.sequelizeConfig.dataSource = {
|
|
23
|
+
default: this.sequelizeConfig.options,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
await this.initDataSource(this.sequelizeConfig);
|
|
27
|
+
}
|
|
28
|
+
getName() {
|
|
29
|
+
return 'sequelize';
|
|
30
|
+
}
|
|
31
|
+
async createDataSource(config, dataSourceName) {
|
|
32
|
+
const client = new sequelize_typescript_1.Sequelize(config);
|
|
33
|
+
const entities = config['entities'];
|
|
34
|
+
if (entities && entities.length > 0) {
|
|
35
|
+
client.addModels(entities);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const entities = (0, decorator_1.listModule)('sequelize:core');
|
|
39
|
+
client.addModels(entities);
|
|
40
|
+
}
|
|
41
|
+
await client.authenticate();
|
|
42
|
+
if (config.sync) {
|
|
43
|
+
await client.sync();
|
|
44
|
+
}
|
|
45
|
+
this.coreLogger.info('[midway:sequelize] connecting and start');
|
|
46
|
+
return client;
|
|
47
|
+
}
|
|
48
|
+
async checkConnected(dataSource) {
|
|
49
|
+
try {
|
|
50
|
+
await dataSource.authenticate();
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
this.coreLogger.error(err);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async destroyDataSource(dataSource) {
|
|
59
|
+
if (await this.checkConnected(dataSource)) {
|
|
60
|
+
await dataSource.close();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, decorator_1.Config)('sequelize'),
|
|
66
|
+
__metadata("design:type", Object)
|
|
67
|
+
], SequelizeDataSourceManager.prototype, "sequelizeConfig", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, decorator_1.Logger)('coreLogger'),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], SequelizeDataSourceManager.prototype, "coreLogger", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, decorator_1.Init)(),
|
|
74
|
+
__metadata("design:type", Function),
|
|
75
|
+
__metadata("design:paramtypes", []),
|
|
76
|
+
__metadata("design:returntype", Promise)
|
|
77
|
+
], SequelizeDataSourceManager.prototype, "init", null);
|
|
78
|
+
SequelizeDataSourceManager = __decorate([
|
|
79
|
+
(0, decorator_1.Provide)(),
|
|
80
|
+
(0, decorator_1.Scope)(decorator_1.ScopeEnum.Singleton)
|
|
81
|
+
], SequelizeDataSourceManager);
|
|
82
|
+
exports.SequelizeDataSourceManager = SequelizeDataSourceManager;
|
|
83
|
+
//# sourceMappingURL=dataSourceManager.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Model, TableOptions } from 'sequelize-typescript';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated
|
|
4
|
+
* @param options
|
|
5
|
+
* @constructor
|
|
6
|
+
*/
|
|
7
|
+
export declare function BaseTable<M extends Model = Model>(options: TableOptions<M>): any;
|
|
8
|
+
export declare function BaseTable(target: any): void;
|
|
9
|
+
export declare const ENTITY_MODEL_KEY = "sequelize:entity_model_key";
|
|
10
|
+
export declare function InjectRepository(modelKey: any, connectionName?: string): PropertyDecorator;
|
|
11
|
+
//# sourceMappingURL=decorator.d.ts.map
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseTable = void 0;
|
|
4
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
3
|
+
exports.InjectRepository = exports.ENTITY_MODEL_KEY = exports.BaseTable = void 0;
|
|
5
4
|
const decorator_1 = require("@midwayjs/decorator");
|
|
5
|
+
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
6
|
+
const decorator_2 = require("@midwayjs/decorator");
|
|
6
7
|
function BaseTable(arg) {
|
|
7
8
|
if (typeof arg === 'function') {
|
|
8
|
-
(0,
|
|
9
|
+
(0, decorator_2.saveModule)('sequelize:core', arg);
|
|
9
10
|
annotate(arg);
|
|
10
11
|
}
|
|
11
12
|
else {
|
|
12
13
|
const options = Object.assign({}, arg);
|
|
13
14
|
return target => {
|
|
14
|
-
(0,
|
|
15
|
+
(0, decorator_2.saveModule)('sequelize:core', target);
|
|
15
16
|
annotate(target, options);
|
|
16
17
|
};
|
|
17
18
|
}
|
|
@@ -21,4 +22,12 @@ function annotate(target, options = {}) {
|
|
|
21
22
|
(0, sequelize_typescript_1.setModelName)(target.prototype, options.modelName || target.name);
|
|
22
23
|
(0, sequelize_typescript_1.addOptions)(target.prototype, options);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
exports.ENTITY_MODEL_KEY = 'sequelize:entity_model_key';
|
|
26
|
+
function InjectRepository(modelKey, connectionName = 'default') {
|
|
27
|
+
return (0, decorator_1.createCustomPropertyDecorator)(exports.ENTITY_MODEL_KEY, {
|
|
28
|
+
modelKey,
|
|
29
|
+
connectionName,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.InjectRepository = InjectRepository;
|
|
33
|
+
//# sourceMappingURL=decorator.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { SequelizeConfiguration as Configuration } from './configuration';
|
|
2
|
-
export { BaseTable } from './
|
|
2
|
+
export { BaseTable, InjectRepository } from './decorator';
|
|
3
|
+
export * from './interface';
|
|
4
|
+
export * from './dataSourceManager';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseTable = exports.Configuration = void 0;
|
|
17
|
+
exports.InjectRepository = exports.BaseTable = exports.Configuration = void 0;
|
|
4
18
|
var configuration_1 = require("./configuration");
|
|
5
19
|
Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.SequelizeConfiguration; } });
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "BaseTable", { enumerable: true, get: function () { return
|
|
20
|
+
var decorator_1 = require("./decorator");
|
|
21
|
+
Object.defineProperty(exports, "BaseTable", { enumerable: true, get: function () { return decorator_1.BaseTable; } });
|
|
22
|
+
Object.defineProperty(exports, "InjectRepository", { enumerable: true, get: function () { return decorator_1.InjectRepository; } });
|
|
23
|
+
__exportStar(require("./interface"), exports);
|
|
24
|
+
__exportStar(require("./dataSourceManager"), exports);
|
|
8
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DataSourceManagerConfigOption } from '@midwayjs/core';
|
|
2
|
+
import { SequelizeOptions } from 'sequelize-typescript';
|
|
3
|
+
export declare type SequelizeConfigOptions = DataSourceManagerConfigOption<SequelizeOptions & {
|
|
4
|
+
sync?: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=interface.d.ts.map
|
package/index.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SequelizeConfigOptions } from './dist';
|
|
2
2
|
|
|
3
3
|
export * from './dist/index';
|
|
4
4
|
|
|
5
5
|
declare module '@midwayjs/core/dist/interface' {
|
|
6
6
|
interface MidwayConfig {
|
|
7
|
-
sequelize?:
|
|
8
|
-
options?: SequelizeOptions;
|
|
9
|
-
sync?: boolean;
|
|
10
|
-
};
|
|
7
|
+
sequelize?: PowerPartial<SequelizeConfigOptions>;
|
|
11
8
|
}
|
|
12
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/sequelize",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-beta.1",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
"index.d.ts"
|
|
10
10
|
],
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@midwayjs/
|
|
13
|
-
"@midwayjs/
|
|
14
|
-
"@midwayjs/
|
|
15
|
-
"
|
|
12
|
+
"@midwayjs/core": "^3.4.0-beta.1",
|
|
13
|
+
"@midwayjs/decorator": "^3.4.0-beta.1",
|
|
14
|
+
"@midwayjs/koa": "^3.4.0-beta.1",
|
|
15
|
+
"@midwayjs/mock": "^3.4.0-beta.1",
|
|
16
|
+
"sqlite3": "5.0.8"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"sequelize": "
|
|
19
|
+
"sequelize": "6.21.0",
|
|
19
20
|
"sequelize-typescript": "^2.1.0"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|
|
@@ -39,6 +40,5 @@
|
|
|
39
40
|
"repository": {
|
|
40
41
|
"type": "git",
|
|
41
42
|
"url": "http://github.com/midwayjs/midway.git"
|
|
42
|
-
}
|
|
43
|
-
"gitHead": "0c2785a87217f57a184a661c71b1d9562af02242"
|
|
43
|
+
}
|
|
44
44
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 - Now midwayjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sequelize = void 0;
|
|
4
|
-
const path = require("path");
|
|
5
|
-
exports.sequelize = {
|
|
6
|
-
options: {
|
|
7
|
-
dialect: 'sqlite',
|
|
8
|
-
storage: path.join(__dirname, '../../test', 'database.sqlite'),
|
|
9
|
-
},
|
|
10
|
-
sync: false,
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=config.default.js.map
|
package/dist/core/baseTable.d.ts
DELETED