leoric 2.1.0 → 2.2.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/History.md +631 -0
- package/package.json +1 -1
- package/src/adapters/sequelize.js +2 -2
- package/src/bone.js +2 -2
- package/src/data_types.js +61 -3
- package/src/drivers/abstract/attribute.js +10 -1
- package/src/drivers/abstract/spellbook.js +2 -4
- package/src/drivers/mysql/spellbook.js +4 -1
- package/src/drivers/postgres/data_types.js +10 -0
- package/types/index.d.ts +16 -5
package/History.md
ADDED
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
2.2.1 / 2022-02-24
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
## What's Changed
|
|
5
|
+
* fix: realm.DataTypes should be invokable by @cyjake in https://github.com/cyjake/leoric/pull/282
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.2.0...v2.2.1
|
|
9
|
+
|
|
10
|
+
2.2.0 / 2022-02-24
|
|
11
|
+
==================
|
|
12
|
+
|
|
13
|
+
## What's Changed
|
|
14
|
+
* fix: add missing `password` field for `ConnectOptions` by @luckydrq in https://github.com/cyjake/leoric/pull/280
|
|
15
|
+
* feat: integer types (mostly mysql specific) by @cyjake in https://github.com/cyjake/leoric/pull/281
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.1.1...v2.2.0
|
|
19
|
+
|
|
20
|
+
2.1.1 / 2022-02-23
|
|
21
|
+
==================
|
|
22
|
+
|
|
23
|
+
## What's Changed
|
|
24
|
+
* fix: fix #274 update with fields option by @JimmyDaddy in https://github.com/cyjake/leoric/pull/275
|
|
25
|
+
* fix: upsert should set createdAt by default while createdAt not set by @JimmyDaddy in https://github.com/cyjake/leoric/pull/277
|
|
26
|
+
* fix: previousChanges should check instance is new record or not while specific attributes' values were undefined by @JimmyDaddy in https://github.com/cyjake/leoric/pull/276
|
|
27
|
+
* docs: add types for realm by @luckydrq in https://github.com/cyjake/leoric/pull/278
|
|
28
|
+
|
|
29
|
+
## New Contributors
|
|
30
|
+
* @luckydrq made their first contribution in https://github.com/cyjake/leoric/pull/278
|
|
31
|
+
|
|
32
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.1.0...v2.1.1
|
|
33
|
+
|
|
34
|
+
2.1.0 / 2022-02-17
|
|
35
|
+
==================
|
|
36
|
+
|
|
37
|
+
## What's Changed
|
|
38
|
+
* feat: fix #270 sequelize mode bulkBuild by @JimmyDaddy in https://github.com/cyjake/leoric/pull/273
|
|
39
|
+
* fix: mysql delete/remove/destroy with limit and orders by @JimmyDaddy in https://github.com/cyjake/leoric/pull/272
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.0.4...v2.1.0
|
|
43
|
+
|
|
44
|
+
2.0.4 / 2022-02-16
|
|
45
|
+
==================
|
|
46
|
+
|
|
47
|
+
## What's Changed
|
|
48
|
+
* fix: fix unit test error by @LB4027221 in https://github.com/cyjake/leoric/pull/269
|
|
49
|
+
* fix: attribute.defaultValue should be set when init attributes by @cyjake in https://github.com/cyjake/leoric/pull/271
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.0.3...v2.0.4
|
|
53
|
+
|
|
54
|
+
2.0.3 / 2022-02-11
|
|
55
|
+
==================
|
|
56
|
+
|
|
57
|
+
## What's Changed
|
|
58
|
+
* fix: default updatedAt to new date if model has no createdAt by @LB4027221 in https://github.com/cyjake/leoric/pull/268
|
|
59
|
+
|
|
60
|
+
## New Contributors
|
|
61
|
+
* @LB4027221 made their first contribution in https://github.com/cyjake/leoric/pull/268
|
|
62
|
+
|
|
63
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.0.2...v2.0.3
|
|
64
|
+
|
|
65
|
+
2.0.2 / 2022-02-10
|
|
66
|
+
==================
|
|
67
|
+
|
|
68
|
+
## What's Changed
|
|
69
|
+
* fix: order by alias should not throw by @cyjake in https://github.com/cyjake/leoric/pull/255
|
|
70
|
+
* fix: fix #257 DataType.uncast should skip Raw type at type checking by @JimmyDaddy in https://github.com/cyjake/leoric/pull/258
|
|
71
|
+
* docs: async function in transaction by @cyjake in https://github.com/cyjake/leoric/pull/259
|
|
72
|
+
* fix: fixed #256 static create instance should check all default attri… by @JimmyDaddy in https://github.com/cyjake/leoric/pull/262
|
|
73
|
+
* fix: fix #260 UPDATE with LIMIT and ORDER should be formatted(mysql only) by @JimmyDaddy in https://github.com/cyjake/leoric/pull/261
|
|
74
|
+
* refactor: keep the UPDATE ... ORDER BY ... LIMIT to mysql driver by @cyjake in https://github.com/cyjake/leoric/pull/264
|
|
75
|
+
* fix: fix #263 upsert attributes should use defaultValue while there i… by @JimmyDaddy in https://github.com/cyjake/leoric/pull/265
|
|
76
|
+
* fix: fix restore Error `Undefined attribute "deletedAt"` by @JimmyDaddy in https://github.com/cyjake/leoric/pull/267
|
|
77
|
+
* fix: type checking adaption by @JimmyDaddy in https://github.com/cyjake/leoric/pull/266
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v2.0.1...v2.0.2
|
|
81
|
+
|
|
82
|
+
2.0.1 / 2022-01-05
|
|
83
|
+
==================
|
|
84
|
+
|
|
85
|
+
## What's Changed
|
|
86
|
+
* fix: format numeric result by @JimmyDaddy in https://github.com/cyjake/leoric/pull/253
|
|
87
|
+
* fix: should still return number if value is '0.000' by @cyjake in https://github.com/cyjake/leoric/pull/254
|
|
88
|
+
|
|
89
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.15.1...v2.0.1
|
|
90
|
+
|
|
91
|
+
2.0.0 / 2021-12-28
|
|
92
|
+
==================
|
|
93
|
+
|
|
94
|
+
## What's Changed
|
|
95
|
+
* breaking: model.sync add force/alter option by @SmartOrange in https://github.com/cyjake/leoric/pull/224
|
|
96
|
+
* breaking: logQueryError(err, sql, duration, options) by @cyjake in https://github.com/cyjake/leoric/pull/237
|
|
97
|
+
* test: add utf8mb4 test cases by @fengmk2 in https://github.com/cyjake/leoric/pull/239
|
|
98
|
+
* Merge 1.x changes by @cyjake in https://github.com/cyjake/leoric/pull/249
|
|
99
|
+
|
|
100
|
+
## New Contributors
|
|
101
|
+
* @SmartOrange made their first contribution in https://github.com/cyjake/leoric/pull/222
|
|
102
|
+
|
|
103
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.15.1...v2.0.0
|
|
104
|
+
|
|
105
|
+
1.15.1 / 2021-12-28
|
|
106
|
+
===================
|
|
107
|
+
|
|
108
|
+
## What's Changed
|
|
109
|
+
* fix: fix #242 date string format by @JimmyDaddy in https://github.com/cyjake/leoric/pull/243
|
|
110
|
+
* fix: update with empty conditions by @JimmyDaddy in https://github.com/cyjake/leoric/pull/241
|
|
111
|
+
* fix: silent option's priority should be lower than valueSet by @JimmyDaddy in https://github.com/cyjake/leoric/pull/244
|
|
112
|
+
* fix: information_schema.columns.datetime_precision by @cyjake in https://github.com/cyjake/leoric/pull/246
|
|
113
|
+
* fix: should not hoist subquery if query is ordered by external columns by @cyjake in https://github.com/cyjake/leoric/pull/247
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.15.0...v1.15.1
|
|
117
|
+
|
|
118
|
+
1.15.0 / 2021-11-22
|
|
119
|
+
===================
|
|
120
|
+
|
|
121
|
+
## What's Changed
|
|
122
|
+
* feat: make duration in precise milliseconds by @fengmk2 in https://github.com/cyjake/leoric/pull/236
|
|
123
|
+
* fix: spell.increment() & spell.decrement() @cyjake https://github.com/cyjake/leoric/pull/234
|
|
124
|
+
* fix: bulkCreate should adapte empty data @JimmyDaddy https://github.com/cyjake/leoric/pull/232
|
|
125
|
+
|
|
126
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.4...v1.14.5
|
|
127
|
+
|
|
128
|
+
1.14.4 / 2021-11-15
|
|
129
|
+
===================
|
|
130
|
+
|
|
131
|
+
## What's Changed
|
|
132
|
+
|
|
133
|
+
* test: PostgreSQL v14 test case compatibility by @cyjake https://github.com/cyjake/leoric/pull/230
|
|
134
|
+
* fix: turn off subquery optimization if query criteria contains other column by @cyjake https://github.com/cyjake/leoric/pull/229
|
|
135
|
+
* fix: bone.changed() return `false | string[]` type by @fengmk2 https://github.com/cyjake/leoric/pull/231
|
|
136
|
+
|
|
137
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.3...v1.14.4
|
|
138
|
+
|
|
139
|
+
1.14.3 / 2021-11-12
|
|
140
|
+
===================
|
|
141
|
+
|
|
142
|
+
## What's Changed
|
|
143
|
+
* fix: logger.logQuery should be guarded in case of error by @SmartOrange in https://github.com/cyjake/leoric/pull/222
|
|
144
|
+
* fix: findOne without result should return null by @JimmyDaddy in https://github.com/cyjake/leoric/pull/225
|
|
145
|
+
* fix: Literal should support bigint type by @fengmk2 in https://github.com/cyjake/leoric/pull/226
|
|
146
|
+
* fix: select((name: string) => boolean) by @cyjake in https://github.com/cyjake/leoric/pull/227
|
|
147
|
+
|
|
148
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.2...v1.14.3
|
|
149
|
+
|
|
150
|
+
1.14.2 / 2021-11-01
|
|
151
|
+
===================
|
|
152
|
+
|
|
153
|
+
## What's Changed
|
|
154
|
+
* fix: accept timestamps in snake case by @cyjake in https://github.com/cyjake/leoric/pull/221
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.1...v1.14.2
|
|
158
|
+
|
|
159
|
+
1.14.1 / 2021-11-01
|
|
160
|
+
===================
|
|
161
|
+
|
|
162
|
+
## What's Changed
|
|
163
|
+
* docs: export { Collection } by @cyjake in https://github.com/cyjake/leoric/pull/220
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.0...v1.14.1
|
|
167
|
+
|
|
168
|
+
1.14.0 / 2021-11-01
|
|
169
|
+
===================
|
|
170
|
+
|
|
171
|
+
Two options regarding `Model.init()` were added in this release:
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
class User extends Bone {}
|
|
175
|
+
User.init({ name: STRING }, {
|
|
176
|
+
timestamps: true, // which is the default
|
|
177
|
+
paranoid: true, // which default to `false`
|
|
178
|
+
});
|
|
179
|
+
assert.deepEqual(Object.keys(User.attributes), [
|
|
180
|
+
'id',
|
|
181
|
+
'name',
|
|
182
|
+
'createdAt',
|
|
183
|
+
'updatedAt',
|
|
184
|
+
'deletedAt',
|
|
185
|
+
]);
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## What's Changed
|
|
189
|
+
* docs: update 'primayKey' typos by @freshgum-bubbles in https://github.com/cyjake/leoric/pull/211
|
|
190
|
+
* docs: DataTypes definitions in d.ts by @cyjake in https://github.com/cyjake/leoric/pull/210
|
|
191
|
+
* fix: fix#209 sequelize mode should update all changed fields in instance update method by @JimmyDaddy in https://github.com/cyjake/leoric/pull/212
|
|
192
|
+
* fix: fix #213 findAndCountAll should ignore attributes by @JimmyDaddy in https://github.com/cyjake/leoric/pull/214
|
|
193
|
+
* fix: opts.connectTimeout by @cyjake in https://github.com/cyjake/leoric/pull/216
|
|
194
|
+
* fix: reload instance with sharding key should not throw by @cyjake in https://github.com/cyjake/leoric/pull/217
|
|
195
|
+
* feat: timestamps should be defined by default by @cyjake in https://github.com/cyjake/leoric/pull/218
|
|
196
|
+
* fix: instance.reload() should not rely on `static findOne()` by @cyjake in https://github.com/cyjake/leoric/pull/219
|
|
197
|
+
|
|
198
|
+
## New Contributors
|
|
199
|
+
* @freshgum-bubbles made their first contribution in https://github.com/cyjake/leoric/pull/211
|
|
200
|
+
|
|
201
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.5...v1.14.0
|
|
202
|
+
|
|
203
|
+
1.13.5 / 2021-10-26
|
|
204
|
+
===================
|
|
205
|
+
|
|
206
|
+
## What's Changed
|
|
207
|
+
* docs: enhance aggregation query types & fix raw query result type by @cyjake in https://github.com/cyjake/leoric/pull/208
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.4...v1.13.5
|
|
211
|
+
|
|
212
|
+
1.13.4 / 2021-10-25
|
|
213
|
+
===================
|
|
214
|
+
|
|
215
|
+
## What's Changed
|
|
216
|
+
* docs: spell & model methods should be generic by @cyjake in https://github.com/cyjake/leoric/pull/206
|
|
217
|
+
* docs: enhance query options, instance type, and toJSON() result type by @cyjake in https://github.com/cyjake/leoric/pull/207
|
|
218
|
+
|
|
219
|
+
This version brings correct (and hopefully better) typescript definitions, with the dts checked continuously at test/types tests. With this version, users that have model types correctly pinned at Bone will get code completion including class fields. Such as:
|
|
220
|
+
|
|
221
|
+

|
|
222
|
+
|
|
223
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.3...v1.13.4
|
|
224
|
+
|
|
225
|
+
1.13.3 / 2021-10-21
|
|
226
|
+
===================
|
|
227
|
+
|
|
228
|
+
## What's Changed
|
|
229
|
+
* refactor: persist edge cases of type casting in integration tests by @cyjake in https://github.com/cyjake/leoric/pull/202
|
|
230
|
+
* docs: renaming attributes by @cyjake in https://github.com/cyjake/leoric/pull/203
|
|
231
|
+
* fix: JSON.uncast(string) should not serialize twice by @cyjake in https://github.com/cyjake/leoric/pull/205
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.2...v1.13.3
|
|
235
|
+
|
|
236
|
+
1.13.2 / 2021-10-18
|
|
237
|
+
===================
|
|
238
|
+
|
|
239
|
+
## What's Changed
|
|
240
|
+
* fix: attribute.uncast([]) and realm.connect with synchronized models by @cyjake in https://github.com/cyjake/leoric/pull/201
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.1...v1.13.2
|
|
244
|
+
|
|
245
|
+
1.13.1 / 2021-10-18
|
|
246
|
+
===================
|
|
247
|
+
|
|
248
|
+
## What's Changed
|
|
249
|
+
* fix: skip connecting if models are synchronized already by @cyjake in https://github.com/cyjake/leoric/pull/200
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.0...v1.13.1
|
|
253
|
+
|
|
254
|
+
1.13.0 / 2021-10-18
|
|
255
|
+
===================
|
|
256
|
+
|
|
257
|
+
## What's Changed
|
|
258
|
+
* docs: monthly updates of 2021.09; support dark mode by @cyjake in https://github.com/cyjake/leoric/pull/196
|
|
259
|
+
* feat: coerce literal values into accurate attribute type by @cyjake in https://github.com/cyjake/leoric/pull/197
|
|
260
|
+
* fix: dispatched result should be in attribute names by @cyjake in https://github.com/cyjake/leoric/pull/198
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
**Full Changelog**: https://github.com/cyjake/leoric/compare/v1.12.0...v1.13.0
|
|
264
|
+
|
|
265
|
+
1.12.0 / 2021-10-12
|
|
266
|
+
===================
|
|
267
|
+
|
|
268
|
+
* feat: support custom fields query and sequelize mode export rawAttributes (#192)
|
|
269
|
+
* refactor: collection format query result (#194)
|
|
270
|
+
* refactor: object condition parsing and expression formatting (#191)
|
|
271
|
+
|
|
272
|
+
1.11.1 / 2021-09-28
|
|
273
|
+
===================
|
|
274
|
+
|
|
275
|
+
This version fixes lots of issues regarding logical operator in object conditions.
|
|
276
|
+
|
|
277
|
+
* fix: logical operator with multiple conditions such as (#190)
|
|
278
|
+
* fix: sequelize mode support HAVING, and select fields raw sql support (#187)
|
|
279
|
+
* fix: support len validator (#188)
|
|
280
|
+
* fix: normalize logical operator conditions before formatting with spellbook (#186)
|
|
281
|
+
|
|
282
|
+
1.11.0 / 2021-09-24
|
|
283
|
+
===================
|
|
284
|
+
|
|
285
|
+
* feat: support BINARY(length), VARBINARY(length), and BLOB (#169)
|
|
286
|
+
* fix: logic operate should adapt one argument (#183)
|
|
287
|
+
* fix: Bone.load() should be idempotent, make sure associations is intact (#184)
|
|
288
|
+
* fix: selected instance isNewRecord is false (#182)
|
|
289
|
+
* fix: set options.busyTimeout to mitigate SQLITE_BUSY (#176)
|
|
290
|
+
* fix: turn on long stack trace of sqlite driver (#175)
|
|
291
|
+
* docs: how to contribute (#180)
|
|
292
|
+
|
|
293
|
+
1.10.0 / 2021-09-14
|
|
294
|
+
===================
|
|
295
|
+
|
|
296
|
+
* feat: SQLite driver should emit "connection" event when new connection is created (#168)
|
|
297
|
+
* fix: bulkCreate(...records) should recognize custom setters (#168)
|
|
298
|
+
* fix: attribute.equals() check should ignore defaultValue (#172)
|
|
299
|
+
|
|
300
|
+
1.9.0 / 2021-09-04
|
|
301
|
+
==================
|
|
302
|
+
|
|
303
|
+
> should've been a major release but since existing users have all migrated to the new api...
|
|
304
|
+
|
|
305
|
+
* breaking: drop the deprecated `Model.describe()` (#167)
|
|
306
|
+
|
|
307
|
+
1.8.0 / 2021-08-30
|
|
308
|
+
==================
|
|
309
|
+
|
|
310
|
+
* feat: silent option fix #164 (#165)
|
|
311
|
+
* feat: binary type (#166)
|
|
312
|
+
|
|
313
|
+
1.7.1 / 2021-08-17
|
|
314
|
+
==================
|
|
315
|
+
|
|
316
|
+
* revert: drop Driver#recycleConnections due to poor interoperability (#162)
|
|
317
|
+
* fix: validator call array arguments (#160)
|
|
318
|
+
|
|
319
|
+
1.7.0 / 2021-08-17
|
|
320
|
+
=================
|
|
321
|
+
|
|
322
|
+
* feat: close connections that exceeds opts.idleTimeout (#159)
|
|
323
|
+
* feat: `opts.connectionLimit` support for SQLite (#159)
|
|
324
|
+
* feat: raw query relpacements, closes #149 (#155)
|
|
325
|
+
* fix: upsert created_at default (#154)
|
|
326
|
+
* test: validator unit test (#157)
|
|
327
|
+
* test: setup_hooks unit test (#158)
|
|
328
|
+
|
|
329
|
+
1.6.7 / 2021-08-05
|
|
330
|
+
==================
|
|
331
|
+
|
|
332
|
+
* fix: prevent from calling Date.prototype.toJSON (#153)
|
|
333
|
+
|
|
334
|
+
1.6.6 / 2021-07-22
|
|
335
|
+
==================
|
|
336
|
+
|
|
337
|
+
* fix: subclassing data type in dialects (#145)
|
|
338
|
+
* fix: where('width / height >= 16 / 9') (#144)
|
|
339
|
+
* docs: logging and sequelzie adapter (zh) (#142)
|
|
340
|
+
* test: include test/unit/utils (#143)
|
|
341
|
+
* test: more tests cases about sequelize adapter (#141)
|
|
342
|
+
|
|
343
|
+
1.6.5 / 2021-07-16
|
|
344
|
+
==================
|
|
345
|
+
|
|
346
|
+
* fix: define assign Bone.models #140
|
|
347
|
+
|
|
348
|
+
1.6.4 / 2021-07-16
|
|
349
|
+
==================
|
|
350
|
+
|
|
351
|
+
* refactor: connect({ Bone }) still necessary (#139)
|
|
352
|
+
* fix: formatting select join with subqueries should not tamper the subquery itself (#138)
|
|
353
|
+
* fix: describe table with more compatible syntax (#137)
|
|
354
|
+
|
|
355
|
+
1.6.3 / 2021-07-14
|
|
356
|
+
==================
|
|
357
|
+
|
|
358
|
+
* fix: transaction option passing in sequelize adapter (#136)
|
|
359
|
+
* fix: this.Model and proper Model.describe() (#135)
|
|
360
|
+
|
|
361
|
+
1.6.2 / 2021-07-09
|
|
362
|
+
==================
|
|
363
|
+
|
|
364
|
+
* fix: convert datetime in seconds/milliseconds back to Date (#134)
|
|
365
|
+
* fix: renamed attribute should remain enumerable (#133)
|
|
366
|
+
|
|
367
|
+
1.6.1 / 2021-07-07
|
|
368
|
+
==================
|
|
369
|
+
|
|
370
|
+
* fix: collection convert should handle tddl results as well (#132)
|
|
371
|
+
|
|
372
|
+
1.6.0 / 2021-07-06
|
|
373
|
+
==================
|
|
374
|
+
|
|
375
|
+
* feat: support class static attributes and hooks (#131)
|
|
376
|
+
* fix: names defined in Bone.attributes should always be enumerable (#128)
|
|
377
|
+
* chore: add quality badge to readme (#129)
|
|
378
|
+
|
|
379
|
+
1.5.2 / 2021-07-02
|
|
380
|
+
==================
|
|
381
|
+
|
|
382
|
+
* fix: leave the getter properties defined in class syntax as is (#127)
|
|
383
|
+
|
|
384
|
+
1.5.1 / 2021-06-30
|
|
385
|
+
==================
|
|
386
|
+
|
|
387
|
+
* fix: export Logger and Spell to let users intercept lower level api calls (#126)
|
|
388
|
+
|
|
389
|
+
1.5.0 / 2021-06-30
|
|
390
|
+
==================
|
|
391
|
+
|
|
392
|
+
* feat: provide Bone.pool to be backward compatible with v0.x (#124)
|
|
393
|
+
* feat: complete bone/spine.restore and Bone API type definitions (#125)
|
|
394
|
+
* feat: support more data types (mediumtext, mediumint, char, date...) (#123)
|
|
395
|
+
|
|
396
|
+
1.4.1 / 2021-06-25
|
|
397
|
+
==================
|
|
398
|
+
|
|
399
|
+
* refactor: simplify legacy timestamps support (#120)
|
|
400
|
+
* refactor: do not subclass Bone unless asked specifically (#120)
|
|
401
|
+
|
|
402
|
+
1.4.0 / 2021-06-24
|
|
403
|
+
==================
|
|
404
|
+
|
|
405
|
+
* feat: `realm.raw('SELECT ...')` and `Model.raw('SELECT ...')` (#94)
|
|
406
|
+
* feat: support multiple order rules in one single string or one-dimensional array (#92)
|
|
407
|
+
* feat: `Model.truncate()` now uses TRUNCATE if possible
|
|
408
|
+
* feat: `Model.find().optimizerHints('SET_VAR(foreign_key_checks=OFF)')`
|
|
409
|
+
* fix: Bone.bulkCreate() should not throw when called with non attribute (#117)
|
|
410
|
+
* fix: batch upsert (#108)
|
|
411
|
+
* fix: make sure connection is passed around in all queries carried out within transaction (#105)
|
|
412
|
+
* fix: update, sequelize mode get API, destroy compitable (#104)
|
|
413
|
+
* fix: `setDataValue` in sequelize adapter should not check prop name strictly
|
|
414
|
+
* refactor: spell_insert (#118)
|
|
415
|
+
* docs: about egg-orm & migrations (#119)
|
|
416
|
+
* docs: revise instructions for installing Jekyll (#111)
|
|
417
|
+
* docs: migrations, validations, hooks, and sequelize adapter (#103)
|
|
418
|
+
* docs: contributing guides
|
|
419
|
+
|
|
420
|
+
1.3.0 / 2021-03-01
|
|
421
|
+
==================
|
|
422
|
+
|
|
423
|
+
* feat: hook support
|
|
424
|
+
* feat: dirty check (`changes()` & `previousChanges()`)
|
|
425
|
+
* feat: compatible with mysql longtext conversion
|
|
426
|
+
* feat: NOT condition
|
|
427
|
+
|
|
428
|
+
1.2.0 / 2020-12-10
|
|
429
|
+
==================
|
|
430
|
+
|
|
431
|
+
* feat: `Realm.prototype.transaction()` with async function support
|
|
432
|
+
* feat: `Realm.prototype.query()` for raw queries
|
|
433
|
+
* feat: `logger.logQuery(sql, duration, { Model, command })`
|
|
434
|
+
* feat: `logger.logQueryError(sql, err, duration, { Model, command })`
|
|
435
|
+
|
|
436
|
+
1.1.0 / 2020-11-23
|
|
437
|
+
==================
|
|
438
|
+
|
|
439
|
+
* feat: JSON and JSONB data types
|
|
440
|
+
* feat: support `stringifyObjects` option for mysql client
|
|
441
|
+
* feat: aggregate functions for sequelize adapter
|
|
442
|
+
* feat: `Spell.prototype.nodeify()`
|
|
443
|
+
|
|
444
|
+
1.0.3 / 2020-03-16
|
|
445
|
+
==================
|
|
446
|
+
|
|
447
|
+
* fix: replace `deep-equal` (which is bloated) with `util.isDeepStrictEqual`
|
|
448
|
+
|
|
449
|
+
1.0.2 / 2020-03-04
|
|
450
|
+
==================
|
|
451
|
+
|
|
452
|
+
* fix: driver.alterTable() with multiple columns to add in SQLite
|
|
453
|
+
|
|
454
|
+
1.0.1 / 2020-02-25
|
|
455
|
+
==================
|
|
456
|
+
|
|
457
|
+
* fix: bulkCreate in sequelize shim
|
|
458
|
+
|
|
459
|
+
1.0.0 / 2020-02-24
|
|
460
|
+
==================
|
|
461
|
+
|
|
462
|
+
First major release. Let's get serious with semver.
|
|
463
|
+
|
|
464
|
+
* feat: logger.logQuery(sql, duration) & logger.logQueryError(sql, err)
|
|
465
|
+
|
|
466
|
+
0.5.3 / 2020-02-22
|
|
467
|
+
==================
|
|
468
|
+
|
|
469
|
+
* fix: `connect({ sequelize, dialect, client })` to allow mandatory sqlite client
|
|
470
|
+
* fix: prevent queries being performed unless model is correctly connected
|
|
471
|
+
|
|
472
|
+
0.5.2 / 2020-02-21
|
|
473
|
+
==================
|
|
474
|
+
|
|
475
|
+
* fix: drop the default and unused `require('sqlite3')`
|
|
476
|
+
|
|
477
|
+
0.5.1 / 2020-02-21
|
|
478
|
+
==================
|
|
479
|
+
|
|
480
|
+
* fix: `connect({ client: '@journeyapps/sqlcipher' })`
|
|
481
|
+
|
|
482
|
+
0.5.0 / 2020-02-19
|
|
483
|
+
==================
|
|
484
|
+
|
|
485
|
+
* feat: `Bone.sync()` to synchronize model with database
|
|
486
|
+
* feat: `Bone.createMigrationFile()` to create migration file
|
|
487
|
+
* feat: `Bone.migrate()` to run migrations
|
|
488
|
+
* feat: `Bone.bulkCreate()` to bulk insert records
|
|
489
|
+
* feat: `require('leoric')` now exports `Realm` to connect with multiple databases
|
|
490
|
+
* feat: `realm.define()` to define models in an old fashioned way
|
|
491
|
+
* feat: `realm.connect()` to connect with database
|
|
492
|
+
* feat: SQLite support without hacking node-sqlite3
|
|
493
|
+
* feat: `Bone.DataTypes` for type references
|
|
494
|
+
* feat: `Bone.init()` to initialize models
|
|
495
|
+
* feat: an adaptor to use Leoric in (partially) Sequelize complaint API
|
|
496
|
+
* refactor: a complete re-write of JOIN queries
|
|
497
|
+
* refactor: added `Bone.driver` to better encapsulate and planish database nuances
|
|
498
|
+
|
|
499
|
+
0.4.5 / 2019-12-14
|
|
500
|
+
==================
|
|
501
|
+
|
|
502
|
+
* fix: prevent primary key from being overridden with incorrect `LAST_INSERT_ID()`
|
|
503
|
+
|
|
504
|
+
0.4.4 / 2019-07-15
|
|
505
|
+
==================
|
|
506
|
+
|
|
507
|
+
* fix: append default scope when declaring relations, fixes #10
|
|
508
|
+
|
|
509
|
+
0.4.3 / 2019-05-09
|
|
510
|
+
==================
|
|
511
|
+
|
|
512
|
+
* fix: prevent Bone.dispatch from creating duplicated records of main table
|
|
513
|
+
|
|
514
|
+
0.4.2 / 2019-04-26
|
|
515
|
+
==================
|
|
516
|
+
|
|
517
|
+
* feat: `Spell#orWhere()` and `Spell#orHaving()`
|
|
518
|
+
* feat: arithmetic operators
|
|
519
|
+
* feat: unary operators such as unary minus `-` and bit invertion `~`
|
|
520
|
+
* fix: unset attribute should be overwritable
|
|
521
|
+
* fix: `attributeChanged()` should be false if attribute is unset and not overwritten
|
|
522
|
+
* fix: subclass with incomplete getter/setter should be complemented
|
|
523
|
+
* fix: sharding key validation on `Bone.update()` and `Bone.save()`
|
|
524
|
+
* fix: sharding key should be along with primary key on `bone.remove()`
|
|
525
|
+
* fix: `Bone.cast()` should leave `null` as is
|
|
526
|
+
* fix: `INSERT ... UPDATE` with `id = LAST_INSERT_ID(id)` in MySQL
|
|
527
|
+
* fix: `Model.find({ name: { $op1, $op2 } })` object conditions with multiple operators
|
|
528
|
+
* fix: prefixing result set with qualifiers if query contains join relations and is not dispatchable
|
|
529
|
+
* fix: `Spell#$get(index)` with LIMIT
|
|
530
|
+
* doc: `Model.transaction()`
|
|
531
|
+
* doc: definition types with `index.d.ts`
|
|
532
|
+
|
|
533
|
+
0.4.1 / 2019-03-21
|
|
534
|
+
==================
|
|
535
|
+
|
|
536
|
+
* feat: premature sharding key validation
|
|
537
|
+
* fix: output complete SQL instead of parameterized query with values.
|
|
538
|
+
* fix: both `connect({ model })` and `connect({ models })` are allowed.
|
|
539
|
+
* doc: no more `.findOrCreate()`, just `.upsert()`
|
|
540
|
+
* doc: table of contents with kramdown's `{:toc}`
|
|
541
|
+
* chore: droped experimental sqlite3 support
|
|
542
|
+
|
|
543
|
+
0.4.0 / 2018-11-05
|
|
544
|
+
==================
|
|
545
|
+
|
|
546
|
+
* feat: PostgreSQL support
|
|
547
|
+
* feat: Transaction support
|
|
548
|
+
* upgrade: (forked) SQLite client updated to SQLite 3.24
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
0.3.0 / 2018-10-31
|
|
552
|
+
==================
|
|
553
|
+
|
|
554
|
+
* feat: SQLite support with a [forked sqlite3](https://github.com/cyjake/node-sqlite3)
|
|
555
|
+
* feat: mysql2 support (which is trivial since both mysql and mysql2 share the same API)
|
|
556
|
+
* refactor: Spell now formats SQL with the literals separated, which gets escaped by the corresponding client itself later on.
|
|
557
|
+
|
|
558
|
+
0.2.0 / 2018-01-03
|
|
559
|
+
==================
|
|
560
|
+
|
|
561
|
+
* breaking: renaming
|
|
562
|
+
|
|
563
|
+
0.1.8 / 2017-12-31
|
|
564
|
+
==================
|
|
565
|
+
|
|
566
|
+
* fix: implement `query.batch()` as async iterator
|
|
567
|
+
* fix: `NOT (expr)`
|
|
568
|
+
* fix: `IFNULL(foo, default)`
|
|
569
|
+
* fix: support `.select(name[])`, `.select(name => {})`, and `.select("...name")`
|
|
570
|
+
* doc: `Model => className` in association options
|
|
571
|
+
* doc: use [jsdoc](http://usejsdoc.org) to generate docs/api
|
|
572
|
+
* doc: `.include()`
|
|
573
|
+
|
|
574
|
+
0.1.7 / 2017-12-22
|
|
575
|
+
==================
|
|
576
|
+
|
|
577
|
+
* refactor: `{ type: 'op', name: 'as' }` renamed to `{ type: 'alias' }`
|
|
578
|
+
* feat: `{ type: 'mod' }` for modifier, currently only `DISTINCT` is recognized
|
|
579
|
+
* feat: unary operators like `!` and `NOT`
|
|
580
|
+
* feat: `IS` and `IS NOT`
|
|
581
|
+
* fix: logic operator precendences
|
|
582
|
+
* fix: polymorphic hasMany({ through }) relations
|
|
583
|
+
* fix: dispatching multiple results with joins correctly
|
|
584
|
+
|
|
585
|
+
0.1.6 / 2017-12-21
|
|
586
|
+
==================
|
|
587
|
+
|
|
588
|
+
* feat: proper `.first`, `.last`, `.all`, and `.get(index)`
|
|
589
|
+
* fix: accept `Date`, `boolean`, and `Set` values
|
|
590
|
+
* fix: `Model.unscoped`
|
|
591
|
+
* fix: `Model.remove({}, true)` should be unscoped
|
|
592
|
+
|
|
593
|
+
0.1.5 / 2017-12-20
|
|
594
|
+
==================
|
|
595
|
+
|
|
596
|
+
* refactor: encapsulate column names. Keep them from the users even if the query results can not be dispatched.
|
|
597
|
+
* fix: complicated groups with joins should discard the use of subquery.
|
|
598
|
+
* fix: camelCase should replace globally
|
|
599
|
+
* fix: avoid missing attribtue exception when toJSON/toObject
|
|
600
|
+
|
|
601
|
+
0.1.4 / 2017-12-18
|
|
602
|
+
==================
|
|
603
|
+
|
|
604
|
+
* fix: should format condition arrays by hand instead of hand it over to formatExpr
|
|
605
|
+
* fix: whereConditions of subquery should retain the order of the whereConditions in major query
|
|
606
|
+
* fix: calculated columns should be kept in the final columns when sorting out the attributes
|
|
607
|
+
* fix: doesn't depend on co anymore
|
|
608
|
+
|
|
609
|
+
0.1.3 / 2017-12-17
|
|
610
|
+
==================
|
|
611
|
+
|
|
612
|
+
* fix: `select distict foo from table`;
|
|
613
|
+
* fix: `where (a = 1 or a = 2) and b = 3`;
|
|
614
|
+
* doc: a syntax table to provide a better glance over the querying ability.
|
|
615
|
+
|
|
616
|
+
0.1.2 / 2017-12-14
|
|
617
|
+
==================
|
|
618
|
+
|
|
619
|
+
* fix: copy left table's orders into subquery to make order/limit work when combined.
|
|
620
|
+
* fix: errors should be thrown when accessing attributes that weren't selected at the first place.
|
|
621
|
+
|
|
622
|
+
0.1.1 / 2017-12-13
|
|
623
|
+
==================
|
|
624
|
+
|
|
625
|
+
* refactor: automatic versioning on spells. When client calls query methods with chaining, new versions of spell gets duplicated. Makes reuse of spells possible.
|
|
626
|
+
* doc: english verion is almost complete <http://cyj.me/leoric>.
|
|
627
|
+
|
|
628
|
+
0.1.0 / 2017-12-09
|
|
629
|
+
==================
|
|
630
|
+
|
|
631
|
+
* Initial version, covers basic usage such as model authoring, database connection, query interface, and association.
|
package/package.json
CHANGED
|
@@ -508,11 +508,11 @@ module.exports = Bone => {
|
|
|
508
508
|
// get isNewRecord() {}
|
|
509
509
|
|
|
510
510
|
async update(values = {}, options = {}) {
|
|
511
|
-
const { fields } = options;
|
|
511
|
+
const { fields = [] } = options;
|
|
512
512
|
const changeValues = {};
|
|
513
513
|
const originalValues = Object.assign({}, this.getRaw());
|
|
514
514
|
for (const name in values) {
|
|
515
|
-
if (values[name] !== undefined && this.hasAttribute(name)) {
|
|
515
|
+
if (values[name] !== undefined && this.hasAttribute(name) && (!fields.length || fields.includes(name))) {
|
|
516
516
|
// exec custom setters in case it exist
|
|
517
517
|
this[name] = values[name];
|
|
518
518
|
changeValues[name] = this.attribute(name);
|
package/src/bone.js
CHANGED
|
@@ -183,7 +183,6 @@ class Bone {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
if (args.length > 1) {
|
|
186
|
-
// execute validators
|
|
187
186
|
this.#raw[name] = value instanceof Raw ? value : attribute.cast(value);
|
|
188
187
|
this.#rawUnset.delete(name);
|
|
189
188
|
return this;
|
|
@@ -619,9 +618,10 @@ class Bone {
|
|
|
619
618
|
async update(values, options = {}) {
|
|
620
619
|
const changes = {};
|
|
621
620
|
const originalValues = Object.assign({}, this.#raw);
|
|
621
|
+
const { fields = [] } = options;
|
|
622
622
|
if (typeof values === 'object') {
|
|
623
623
|
for (const name in values) {
|
|
624
|
-
if (values[name] !== undefined && this.hasAttribute(name)) {
|
|
624
|
+
if (values[name] !== undefined && this.hasAttribute(name) && (!fields.length || fields.includes(name))) {
|
|
625
625
|
// exec custom setters in case it exist
|
|
626
626
|
this[name] = values[name];
|
|
627
627
|
changes[name] = this.attribute(name);
|
package/src/data_types.js
CHANGED
|
@@ -14,7 +14,13 @@ const Raw = require('./raw');
|
|
|
14
14
|
|
|
15
15
|
class DataType {
|
|
16
16
|
static findType(columnType) {
|
|
17
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
STRING, TEXT,
|
|
19
|
+
DATE, DATEONLY,
|
|
20
|
+
TINYINT, SMALLINT, MEDIUMINT, INTEGER, BIGINT,
|
|
21
|
+
BOOLEAN,
|
|
22
|
+
BINARY, VARBINARY, BLOB,
|
|
23
|
+
} = this;
|
|
18
24
|
const [ , dataType, appendix ] = columnType.match(/(\w+)(?:\((\d+)\))?/);
|
|
19
25
|
const length = appendix && parseInt(appendix, 10);
|
|
20
26
|
|
|
@@ -39,10 +45,13 @@ class DataType {
|
|
|
39
45
|
case 'int':
|
|
40
46
|
case 'integer':
|
|
41
47
|
case 'numeric':
|
|
48
|
+
return new INTEGER(length);
|
|
42
49
|
case 'mediumint':
|
|
50
|
+
return new MEDIUMINT(length);
|
|
43
51
|
case 'smallint':
|
|
52
|
+
return new SMALLINT(length);
|
|
44
53
|
case 'tinyint':
|
|
45
|
-
return new
|
|
54
|
+
return new TINYINT(length);
|
|
46
55
|
case 'bigint':
|
|
47
56
|
return new BIGINT(length);
|
|
48
57
|
case 'boolean':
|
|
@@ -203,12 +212,58 @@ class INTEGER extends DataType {
|
|
|
203
212
|
}
|
|
204
213
|
}
|
|
205
214
|
|
|
215
|
+
/**
|
|
216
|
+
* 8 bit integer
|
|
217
|
+
* @example
|
|
218
|
+
* TINYINT
|
|
219
|
+
* TINYINT.UNSIGNED
|
|
220
|
+
* TINYINT(1)
|
|
221
|
+
* @param {number} length
|
|
222
|
+
*/
|
|
223
|
+
class TINYINT extends INTEGER {
|
|
224
|
+
constructor(length) {
|
|
225
|
+
super(length);
|
|
226
|
+
this.dataType = 'tinyint';
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 16 bit integer
|
|
232
|
+
* @example
|
|
233
|
+
* SMALLINT
|
|
234
|
+
* SMALLINT.UNSIGNED
|
|
235
|
+
* SMALLINT(2)
|
|
236
|
+
* @param {number} length
|
|
237
|
+
*/
|
|
238
|
+
class SMALLINT extends INTEGER {
|
|
239
|
+
constructor(length) {
|
|
240
|
+
super(length);
|
|
241
|
+
this.dataType = 'smallint';
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 24 bit integer
|
|
247
|
+
* @example
|
|
248
|
+
* MEDIUMINT
|
|
249
|
+
* MEDIUMINT.UNSIGNED
|
|
250
|
+
* MEDIUMINT(3)
|
|
251
|
+
* @param {number} length
|
|
252
|
+
*/
|
|
253
|
+
class MEDIUMINT extends INTEGER {
|
|
254
|
+
constructor(length) {
|
|
255
|
+
super(length);
|
|
256
|
+
this.dataType = 'mediumint';
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
|
|
206
261
|
/**
|
|
207
262
|
* 64 bit integer
|
|
208
263
|
* @example
|
|
209
264
|
* BIGINT
|
|
210
265
|
* BIGINT.UNSIGNED
|
|
211
|
-
* BIGINT(
|
|
266
|
+
* BIGINT(8)
|
|
212
267
|
* @param {number} length
|
|
213
268
|
*/
|
|
214
269
|
class BIGINT extends INTEGER {
|
|
@@ -422,6 +477,9 @@ class JSONB extends JSON {
|
|
|
422
477
|
|
|
423
478
|
const DataTypes = {
|
|
424
479
|
STRING,
|
|
480
|
+
TINYINT,
|
|
481
|
+
SMALLINT,
|
|
482
|
+
MEDIUMINT,
|
|
425
483
|
INTEGER,
|
|
426
484
|
BIGINT,
|
|
427
485
|
DATE,
|
|
@@ -65,6 +65,14 @@ function createType(DataTypes, params) {
|
|
|
65
65
|
switch (type.constructor.name) {
|
|
66
66
|
case 'DATE':
|
|
67
67
|
return new DataType(type.precision, type.timezone);
|
|
68
|
+
case 'TINYINT':
|
|
69
|
+
case 'SMALLINT':
|
|
70
|
+
case 'MEDIUMINT':
|
|
71
|
+
case 'INTEGER':
|
|
72
|
+
case 'BIGINT':
|
|
73
|
+
case 'BINARY':
|
|
74
|
+
case 'VARBINARY':
|
|
75
|
+
return new DataType(type.length);
|
|
68
76
|
default:
|
|
69
77
|
return new DataType();
|
|
70
78
|
}
|
|
@@ -123,7 +131,8 @@ class Attribute {
|
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
cast(value) {
|
|
126
|
-
|
|
134
|
+
const castedValue = this.type.cast(value);
|
|
135
|
+
return castedValue == null? null : castedValue;
|
|
127
136
|
}
|
|
128
137
|
|
|
129
138
|
uncast(value, strict = true) {
|
|
@@ -356,15 +356,14 @@ function formatInsert(spell) {
|
|
|
356
356
|
}
|
|
357
357
|
} else {
|
|
358
358
|
for (const name in involved) {
|
|
359
|
-
// upsert should not update createdAt
|
|
360
|
-
if (updateOnDuplicate && createdAt && name === createdAt) continue;
|
|
361
359
|
attributes.push(Model.attributes[name]);
|
|
362
360
|
}
|
|
363
361
|
}
|
|
364
362
|
|
|
365
363
|
for (const entry of attributes) {
|
|
366
364
|
columns.push(entry.columnName);
|
|
367
|
-
if (updateOnDuplicate && createdAt && entry.name === createdAt
|
|
365
|
+
if (updateOnDuplicate && createdAt && entry.name === createdAt
|
|
366
|
+
&& !(Array.isArray(updateOnDuplicate) && updateOnDuplicate.includes(createdAt))) continue;
|
|
368
367
|
updateOnDuplicateColumns.push(entry.columnName);
|
|
369
368
|
}
|
|
370
369
|
|
|
@@ -385,7 +384,6 @@ function formatInsert(spell) {
|
|
|
385
384
|
}
|
|
386
385
|
for (const name in sets) {
|
|
387
386
|
const value = sets[name];
|
|
388
|
-
// upsert should not update createdAt
|
|
389
387
|
columns.push(Model.unalias(name));
|
|
390
388
|
if (value instanceof Raw) {
|
|
391
389
|
values.push(SqlString.raw(value.value));
|
|
@@ -49,7 +49,10 @@ module.exports = {
|
|
|
49
49
|
const sets = [];
|
|
50
50
|
// Make sure the correct LAST_INSERT_ID is returned.
|
|
51
51
|
// - https://stackoverflow.com/questions/778534/mysql-on-duplicate-key-last-insert-id
|
|
52
|
-
|
|
52
|
+
// if insert attributes include primary column, `primaryKey = LAST_INSERT_ID(primaryKey)` is not need any more
|
|
53
|
+
if (!columns.includes(primaryColumn)) {
|
|
54
|
+
sets.push(`${escapeId(primaryColumn)} = LAST_INSERT_ID(${escapeId(primaryColumn)})`);
|
|
55
|
+
}
|
|
53
56
|
sets.push(...columns.map(column => `${escapeId(column)}=VALUES(${escapeId(column)})`));
|
|
54
57
|
|
|
55
58
|
return `ON DUPLICATE KEY UPDATE ${sets.join(', ')}`;
|
|
@@ -61,12 +61,22 @@ class Postgres_BIGINT extends Postgres_INTEGER {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
class Postgres_SMALLINT extends Postgres_INTEGER {
|
|
65
|
+
constructor() {
|
|
66
|
+
super();
|
|
67
|
+
this.dataType = 'smallint';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
class Postgres_DataTypes extends DataTypes {
|
|
65
72
|
static DATE = Postgres_DATE;
|
|
66
73
|
static JSONB = Postgres_JSONB;
|
|
67
74
|
static BINARY = Postgres_BINARY;
|
|
68
75
|
static VARBINARY = Postgres_BINARY;
|
|
69
76
|
static BLOB = Postgres_BINARY;
|
|
77
|
+
static TINYINT = Postgres_SMALLINT;
|
|
78
|
+
static SMALLINT = Postgres_SMALLINT;
|
|
79
|
+
static MEDIUMINT = Postgres_INTEGER;
|
|
70
80
|
static INTEGER = Postgres_INTEGER;
|
|
71
81
|
static BIGINT = Postgres_BIGINT;
|
|
72
82
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -593,13 +593,16 @@ export class Bone {
|
|
|
593
593
|
toObject(): InstanceValues<this>;
|
|
594
594
|
}
|
|
595
595
|
|
|
596
|
-
interface ConnectOptions {
|
|
596
|
+
export interface ConnectOptions {
|
|
597
597
|
client?: 'mysql' | 'mysql2' | 'pg' | 'sqlite3' | '@journeyapps/sqlcipher';
|
|
598
598
|
dialect?: 'mysql' | 'postgres' | 'sqlite';
|
|
599
599
|
host?: string;
|
|
600
|
+
port?: number | string;
|
|
600
601
|
user?: string;
|
|
602
|
+
password?: string;
|
|
601
603
|
database: string;
|
|
602
604
|
models?: string | (typeof Bone)[];
|
|
605
|
+
subclass?: boolean;
|
|
603
606
|
}
|
|
604
607
|
|
|
605
608
|
interface InitOptions {
|
|
@@ -612,6 +615,11 @@ interface InitOptions {
|
|
|
612
615
|
};
|
|
613
616
|
}
|
|
614
617
|
|
|
618
|
+
interface SyncOptions {
|
|
619
|
+
force?: boolean;
|
|
620
|
+
alter?: boolean;
|
|
621
|
+
}
|
|
622
|
+
|
|
615
623
|
type RawSql = {
|
|
616
624
|
__raw: true,
|
|
617
625
|
value: string,
|
|
@@ -626,6 +634,7 @@ interface RawQueryOptions {
|
|
|
626
634
|
|
|
627
635
|
export default class Realm {
|
|
628
636
|
Bone: typeof Bone;
|
|
637
|
+
DataTypes: typeof DataType;
|
|
629
638
|
driver: Driver;
|
|
630
639
|
models: Record<string, Bone>;
|
|
631
640
|
|
|
@@ -633,10 +642,10 @@ export default class Realm {
|
|
|
633
642
|
|
|
634
643
|
define(
|
|
635
644
|
name: string,
|
|
636
|
-
attributes: Record<string, AttributeMeta>,
|
|
637
|
-
options
|
|
638
|
-
descriptors
|
|
639
|
-
): Bone;
|
|
645
|
+
attributes: Record<string, DataTypes<DataType> | AttributeMeta>,
|
|
646
|
+
options?: InitOptions,
|
|
647
|
+
descriptors?: Record<string, Function>,
|
|
648
|
+
): typeof Bone;
|
|
640
649
|
|
|
641
650
|
raw(sql: string): RawSql;
|
|
642
651
|
|
|
@@ -646,6 +655,8 @@ export default class Realm {
|
|
|
646
655
|
|
|
647
656
|
transaction(callback: GeneratorFunction): Promise<void>;
|
|
648
657
|
transaction(callback: (connection: Connection) => Promise<void>): Promise<void>;
|
|
658
|
+
|
|
659
|
+
sync(options?: SyncOptions): Promise<void>;
|
|
649
660
|
}
|
|
650
661
|
|
|
651
662
|
/**
|