leoric 2.0.4 → 2.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leoric",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "JavaScript Object-relational mapping alchemy",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -257,6 +257,17 @@ module.exports = Bone => {
257
257
  return instance;
258
258
  }
259
259
 
260
+ /**
261
+ * see https://github.com/sequelize/sequelize/blob/a729c4df41fa3a58fbecaf879265d2fb73d80e5f/src/model.js#L2299
262
+ * @param {Array<Object>} valueSets
263
+ * @param {Object} options
264
+ * @returns
265
+ */
266
+ static bulkBuild(valueSets, options = {}) {
267
+ if (!valueSets.length) return [];
268
+ return valueSets.map(value => this.build(value, options));
269
+ }
270
+
260
271
  // EXISTS
261
272
  // static bulkCreate() {}
262
273
 
@@ -308,7 +319,9 @@ module.exports = Bone => {
308
319
  // proxy to class.destroy({ individualHooks=false }) see https://github.com/sequelize/sequelize/blob/4063c2ab627ad57919d5b45cc7755f077a69fa5e/lib/model.js#L2895 before(after)BulkDestroy
309
320
  static async bulkDestroy(options = {}) {
310
321
  const { where, force } = options;
311
- return await this.remove(where || {}, force, { ...options });
322
+ const spell = this._remove(where || {}, force, { ...options });
323
+ translateOptions(spell, options);
324
+ return spell;
312
325
  }
313
326
 
314
327
  // EXISTS
package/src/bone.js CHANGED
@@ -789,7 +789,7 @@ class Bone {
789
789
  }, opts);
790
790
  return result;
791
791
  }
792
- return await Model.remove(condition, forceDelete, { hooks: false, ...opts });
792
+ return await Model._remove(condition, forceDelete, opts);
793
793
  }
794
794
 
795
795
  /**
@@ -1454,6 +1454,24 @@ class Bone {
1454
1454
  * @return {Spell}
1455
1455
  */
1456
1456
  static remove(conditions, forceDelete = false, options) {
1457
+ return this._remove(conditions, forceDelete, options);
1458
+ }
1459
+
1460
+ /**
1461
+ * private method for internal calling
1462
+ * Remove any record that matches `conditions`.
1463
+ * - If `forceDelete` is true, `DELETE` records from database permanently.
1464
+ * - If not, update `deletedAt` attribute with current date.
1465
+ * - If `forceDelete` isn't true and `deleteAt` isn't around, throw an Error.
1466
+ * @example
1467
+ * Post.remove({ title: 'Leah' }) // mark Post { title: 'Leah' } as deleted
1468
+ * Post.remove({ title: 'Leah' }, true) // delete Post { title: 'Leah' }
1469
+ * Post.remove({}, true) // delete all data of posts
1470
+ * @param {Object} conditions
1471
+ * @param {boolean} forceDelete
1472
+ * @return {Spell}
1473
+ */
1474
+ static _remove(conditions, forceDelete = false, options) {
1457
1475
  const { deletedAt } = this.timestamps;
1458
1476
  if (forceDelete !== true && this.attributes[deletedAt]) {
1459
1477
  return Bone.update.call(this, conditions, { [deletedAt]: new Date() }, {
@@ -75,4 +75,19 @@ module.exports = {
75
75
 
76
76
  return result;
77
77
  },
78
+ /**
79
+ * DELETE ... ORDER BY ...LIMIT
80
+ * @param {Spell} spell
81
+ */
82
+ formatDelete(spell) {
83
+ const result = spellbook.formatDelete.call(this, spell);
84
+ const { rowCount, orders } = spell;
85
+ const chunks = [];
86
+
87
+ if (orders.length > 0) chunks.push(`ORDER BY ${this.formatOrders(spell, orders).join(', ')}`);
88
+ if (rowCount > 0) chunks.push(`LIMIT ${rowCount}`);
89
+ if (chunks.length > 0) result.sql += ` ${chunks.join(' ')}`;
90
+
91
+ return result;
92
+ }
78
93
  };
package/History.md DELETED
@@ -1,588 +0,0 @@
1
- 2.0.4 / 2022-02-16
2
- ==================
3
-
4
- ## What's Changed
5
- * fix: fix unit test error by @LB4027221 in https://github.com/cyjake/leoric/pull/269
6
- * fix: attribute.defaultValue should be set when init attributes by @cyjake in https://github.com/cyjake/leoric/pull/271
7
-
8
-
9
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v2.0.3...v2.0.4
10
-
11
- 2.0.3 / 2022-02-11
12
- ==================
13
-
14
- ## What's Changed
15
- * fix: default updatedAt to new date if model has no createdAt by @LB4027221 in https://github.com/cyjake/leoric/pull/268
16
-
17
- ## New Contributors
18
- * @LB4027221 made their first contribution in https://github.com/cyjake/leoric/pull/268
19
-
20
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v2.0.2...v2.0.3
21
-
22
- 2.0.2 / 2022-02-10
23
- ==================
24
-
25
- ## What's Changed
26
- * fix: order by alias should not throw by @cyjake in https://github.com/cyjake/leoric/pull/255
27
- * fix: fix #257 DataType.uncast should skip Raw type at type checking by @JimmyDaddy in https://github.com/cyjake/leoric/pull/258
28
- * docs: async function in transaction by @cyjake in https://github.com/cyjake/leoric/pull/259
29
- * fix: fixed #256 static create instance should check all default attri… by @JimmyDaddy in https://github.com/cyjake/leoric/pull/262
30
- * fix: fix #260 UPDATE with LIMIT and ORDER should be formatted(mysql only) by @JimmyDaddy in https://github.com/cyjake/leoric/pull/261
31
- * refactor: keep the UPDATE ... ORDER BY ... LIMIT to mysql driver by @cyjake in https://github.com/cyjake/leoric/pull/264
32
- * fix: fix #263 upsert attributes should use defaultValue while there i… by @JimmyDaddy in https://github.com/cyjake/leoric/pull/265
33
- * fix: fix restore Error `Undefined attribute "deletedAt"` by @JimmyDaddy in https://github.com/cyjake/leoric/pull/267
34
- * fix: type checking adaption by @JimmyDaddy in https://github.com/cyjake/leoric/pull/266
35
-
36
-
37
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v2.0.1...v2.0.2
38
-
39
- 2.0.1 / 2022-01-05
40
- ==================
41
-
42
- ## What's Changed
43
- * fix: format numeric result by @JimmyDaddy in https://github.com/cyjake/leoric/pull/253
44
- * fix: should still return number if value is '0.000' by @cyjake in https://github.com/cyjake/leoric/pull/254
45
-
46
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.15.1...v2.0.1
47
-
48
- 2.0.0 / 2021-12-28
49
- ==================
50
-
51
- ## What's Changed
52
- * breaking: model.sync add force/alter option by @SmartOrange in https://github.com/cyjake/leoric/pull/224
53
- * breaking: logQueryError(err, sql, duration, options) by @cyjake in https://github.com/cyjake/leoric/pull/237
54
- * test: add utf8mb4 test cases by @fengmk2 in https://github.com/cyjake/leoric/pull/239
55
- * Merge 1.x changes by @cyjake in https://github.com/cyjake/leoric/pull/249
56
-
57
- ## New Contributors
58
- * @SmartOrange made their first contribution in https://github.com/cyjake/leoric/pull/222
59
-
60
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.15.1...v2.0.0
61
-
62
- 1.15.1 / 2021-12-28
63
- ===================
64
-
65
- ## What's Changed
66
- * fix: fix #242 date string format by @JimmyDaddy in https://github.com/cyjake/leoric/pull/243
67
- * fix: update with empty conditions by @JimmyDaddy in https://github.com/cyjake/leoric/pull/241
68
- * fix: silent option's priority should be lower than valueSet by @JimmyDaddy in https://github.com/cyjake/leoric/pull/244
69
- * fix: information_schema.columns.datetime_precision by @cyjake in https://github.com/cyjake/leoric/pull/246
70
- * fix: should not hoist subquery if query is ordered by external columns by @cyjake in https://github.com/cyjake/leoric/pull/247
71
-
72
-
73
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.15.0...v1.15.1
74
-
75
- 1.15.0 / 2021-11-22
76
- ===================
77
-
78
- ## What's Changed
79
- * feat: make duration in precise milliseconds by @fengmk2 in https://github.com/cyjake/leoric/pull/236
80
- * fix: spell.increment() & spell.decrement() @cyjake https://github.com/cyjake/leoric/pull/234
81
- * fix: bulkCreate should adapte empty data @JimmyDaddy https://github.com/cyjake/leoric/pull/232
82
-
83
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.4...v1.14.5
84
-
85
- 1.14.4 / 2021-11-15
86
- ===================
87
-
88
- ## What's Changed
89
-
90
- * test: PostgreSQL v14 test case compatibility by @cyjake https://github.com/cyjake/leoric/pull/230
91
- * fix: turn off subquery optimization if query criteria contains other column by @cyjake https://github.com/cyjake/leoric/pull/229
92
- * fix: bone.changed() return `false | string[]` type by @fengmk2 https://github.com/cyjake/leoric/pull/231
93
-
94
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.3...v1.14.4
95
-
96
- 1.14.3 / 2021-11-12
97
- ===================
98
-
99
- ## What's Changed
100
- * fix: logger.logQuery should be guarded in case of error by @SmartOrange in https://github.com/cyjake/leoric/pull/222
101
- * fix: findOne without result should return null by @JimmyDaddy in https://github.com/cyjake/leoric/pull/225
102
- * fix: Literal should support bigint type by @fengmk2 in https://github.com/cyjake/leoric/pull/226
103
- * fix: select((name: string) => boolean) by @cyjake in https://github.com/cyjake/leoric/pull/227
104
-
105
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.2...v1.14.3
106
-
107
- 1.14.2 / 2021-11-01
108
- ===================
109
-
110
- ## What's Changed
111
- * fix: accept timestamps in snake case by @cyjake in https://github.com/cyjake/leoric/pull/221
112
-
113
-
114
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.1...v1.14.2
115
-
116
- 1.14.1 / 2021-11-01
117
- ===================
118
-
119
- ## What's Changed
120
- * docs: export { Collection } by @cyjake in https://github.com/cyjake/leoric/pull/220
121
-
122
-
123
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.14.0...v1.14.1
124
-
125
- 1.14.0 / 2021-11-01
126
- ===================
127
-
128
- Two options regarding `Model.init()` were added in this release:
129
-
130
- ```js
131
- class User extends Bone {}
132
- User.init({ name: STRING }, {
133
- timestamps: true, // which is the default
134
- paranoid: true, // which default to `false`
135
- });
136
- assert.deepEqual(Object.keys(User.attributes), [
137
- 'id',
138
- 'name',
139
- 'createdAt',
140
- 'updatedAt',
141
- 'deletedAt',
142
- ]);
143
- ```
144
-
145
- ## What's Changed
146
- * docs: update 'primayKey' typos by @freshgum-bubbles in https://github.com/cyjake/leoric/pull/211
147
- * docs: DataTypes definitions in d.ts by @cyjake in https://github.com/cyjake/leoric/pull/210
148
- * fix: fix#209 sequelize mode should update all changed fields in instance update method by @JimmyDaddy in https://github.com/cyjake/leoric/pull/212
149
- * fix: fix #213 findAndCountAll should ignore attributes by @JimmyDaddy in https://github.com/cyjake/leoric/pull/214
150
- * fix: opts.connectTimeout by @cyjake in https://github.com/cyjake/leoric/pull/216
151
- * fix: reload instance with sharding key should not throw by @cyjake in https://github.com/cyjake/leoric/pull/217
152
- * feat: timestamps should be defined by default by @cyjake in https://github.com/cyjake/leoric/pull/218
153
- * fix: instance.reload() should not rely on `static findOne()` by @cyjake in https://github.com/cyjake/leoric/pull/219
154
-
155
- ## New Contributors
156
- * @freshgum-bubbles made their first contribution in https://github.com/cyjake/leoric/pull/211
157
-
158
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.5...v1.14.0
159
-
160
- 1.13.5 / 2021-10-26
161
- ===================
162
-
163
- ## What's Changed
164
- * docs: enhance aggregation query types & fix raw query result type by @cyjake in https://github.com/cyjake/leoric/pull/208
165
-
166
-
167
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.4...v1.13.5
168
-
169
- 1.13.4 / 2021-10-25
170
- ===================
171
-
172
- ## What's Changed
173
- * docs: spell & model methods should be generic by @cyjake in https://github.com/cyjake/leoric/pull/206
174
- * docs: enhance query options, instance type, and toJSON() result type by @cyjake in https://github.com/cyjake/leoric/pull/207
175
-
176
- 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:
177
-
178
- ![image](https://user-images.githubusercontent.com/252317/138683240-98ee9e79-4b3e-449c-bc95-a449d457d64f.png)
179
-
180
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.3...v1.13.4
181
-
182
- 1.13.3 / 2021-10-21
183
- ===================
184
-
185
- ## What's Changed
186
- * refactor: persist edge cases of type casting in integration tests by @cyjake in https://github.com/cyjake/leoric/pull/202
187
- * docs: renaming attributes by @cyjake in https://github.com/cyjake/leoric/pull/203
188
- * fix: JSON.uncast(string) should not serialize twice by @cyjake in https://github.com/cyjake/leoric/pull/205
189
-
190
-
191
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.2...v1.13.3
192
-
193
- 1.13.2 / 2021-10-18
194
- ===================
195
-
196
- ## What's Changed
197
- * fix: attribute.uncast([]) and realm.connect with synchronized models by @cyjake in https://github.com/cyjake/leoric/pull/201
198
-
199
-
200
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.1...v1.13.2
201
-
202
- 1.13.1 / 2021-10-18
203
- ===================
204
-
205
- ## What's Changed
206
- * fix: skip connecting if models are synchronized already by @cyjake in https://github.com/cyjake/leoric/pull/200
207
-
208
-
209
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.13.0...v1.13.1
210
-
211
- 1.13.0 / 2021-10-18
212
- ===================
213
-
214
- ## What's Changed
215
- * docs: monthly updates of 2021.09; support dark mode by @cyjake in https://github.com/cyjake/leoric/pull/196
216
- * feat: coerce literal values into accurate attribute type by @cyjake in https://github.com/cyjake/leoric/pull/197
217
- * fix: dispatched result should be in attribute names by @cyjake in https://github.com/cyjake/leoric/pull/198
218
-
219
-
220
- **Full Changelog**: https://github.com/cyjake/leoric/compare/v1.12.0...v1.13.0
221
-
222
- 1.12.0 / 2021-10-12
223
- ===================
224
-
225
- * feat: support custom fields query and sequelize mode export rawAttributes (#192)
226
- * refactor: collection format query result (#194)
227
- * refactor: object condition parsing and expression formatting (#191)
228
-
229
- 1.11.1 / 2021-09-28
230
- ===================
231
-
232
- This version fixes lots of issues regarding logical operator in object conditions.
233
-
234
- * fix: logical operator with multiple conditions such as (#190)
235
- * fix: sequelize mode support HAVING, and select fields raw sql support (#187)
236
- * fix: support len validator (#188)
237
- * fix: normalize logical operator conditions before formatting with spellbook (#186)
238
-
239
- 1.11.0 / 2021-09-24
240
- ===================
241
-
242
- * feat: support BINARY(length), VARBINARY(length), and BLOB (#169)
243
- * fix: logic operate should adapt one argument (#183)
244
- * fix: Bone.load() should be idempotent, make sure associations is intact (#184)
245
- * fix: selected instance isNewRecord is false (#182)
246
- * fix: set options.busyTimeout to mitigate SQLITE_BUSY (#176)
247
- * fix: turn on long stack trace of sqlite driver (#175)
248
- * docs: how to contribute (#180)
249
-
250
- 1.10.0 / 2021-09-14
251
- ===================
252
-
253
- * feat: SQLite driver should emit "connection" event when new connection is created (#168)
254
- * fix: bulkCreate(...records) should recognize custom setters (#168)
255
- * fix: attribute.equals() check should ignore defaultValue (#172)
256
-
257
- 1.9.0 / 2021-09-04
258
- ==================
259
-
260
- > should've been a major release but since existing users have all migrated to the new api...
261
-
262
- * breaking: drop the deprecated `Model.describe()` (#167)
263
-
264
- 1.8.0 / 2021-08-30
265
- ==================
266
-
267
- * feat: silent option fix #164 (#165)
268
- * feat: binary type (#166)
269
-
270
- 1.7.1 / 2021-08-17
271
- ==================
272
-
273
- * revert: drop Driver#recycleConnections due to poor interoperability (#162)
274
- * fix: validator call array arguments (#160)
275
-
276
- 1.7.0 / 2021-08-17
277
- =================
278
-
279
- * feat: close connections that exceeds opts.idleTimeout (#159)
280
- * feat: `opts.connectionLimit` support for SQLite (#159)
281
- * feat: raw query relpacements, closes #149 (#155)
282
- * fix: upsert created_at default (#154)
283
- * test: validator unit test (#157)
284
- * test: setup_hooks unit test (#158)
285
-
286
- 1.6.7 / 2021-08-05
287
- ==================
288
-
289
- * fix: prevent from calling Date.prototype.toJSON (#153)
290
-
291
- 1.6.6 / 2021-07-22
292
- ==================
293
-
294
- * fix: subclassing data type in dialects (#145)
295
- * fix: where('width / height >= 16 / 9') (#144)
296
- * docs: logging and sequelzie adapter (zh) (#142)
297
- * test: include test/unit/utils (#143)
298
- * test: more tests cases about sequelize adapter (#141)
299
-
300
- 1.6.5 / 2021-07-16
301
- ==================
302
-
303
- * fix: define assign Bone.models #140
304
-
305
- 1.6.4 / 2021-07-16
306
- ==================
307
-
308
- * refactor: connect({ Bone }) still necessary (#139)
309
- * fix: formatting select join with subqueries should not tamper the subquery itself (#138)
310
- * fix: describe table with more compatible syntax (#137)
311
-
312
- 1.6.3 / 2021-07-14
313
- ==================
314
-
315
- * fix: transaction option passing in sequelize adapter (#136)
316
- * fix: this.Model and proper Model.describe() (#135)
317
-
318
- 1.6.2 / 2021-07-09
319
- ==================
320
-
321
- * fix: convert datetime in seconds/milliseconds back to Date (#134)
322
- * fix: renamed attribute should remain enumerable (#133)
323
-
324
- 1.6.1 / 2021-07-07
325
- ==================
326
-
327
- * fix: collection convert should handle tddl results as well (#132)
328
-
329
- 1.6.0 / 2021-07-06
330
- ==================
331
-
332
- * feat: support class static attributes and hooks (#131)
333
- * fix: names defined in Bone.attributes should always be enumerable (#128)
334
- * chore: add quality badge to readme (#129)
335
-
336
- 1.5.2 / 2021-07-02
337
- ==================
338
-
339
- * fix: leave the getter properties defined in class syntax as is (#127)
340
-
341
- 1.5.1 / 2021-06-30
342
- ==================
343
-
344
- * fix: export Logger and Spell to let users intercept lower level api calls (#126)
345
-
346
- 1.5.0 / 2021-06-30
347
- ==================
348
-
349
- * feat: provide Bone.pool to be backward compatible with v0.x (#124)
350
- * feat: complete bone/spine.restore and Bone API type definitions (#125)
351
- * feat: support more data types (mediumtext, mediumint, char, date...) (#123)
352
-
353
- 1.4.1 / 2021-06-25
354
- ==================
355
-
356
- * refactor: simplify legacy timestamps support (#120)
357
- * refactor: do not subclass Bone unless asked specifically (#120)
358
-
359
- 1.4.0 / 2021-06-24
360
- ==================
361
-
362
- * feat: `realm.raw('SELECT ...')` and `Model.raw('SELECT ...')` (#94)
363
- * feat: support multiple order rules in one single string or one-dimensional array (#92)
364
- * feat: `Model.truncate()` now uses TRUNCATE if possible
365
- * feat: `Model.find().optimizerHints('SET_VAR(foreign_key_checks=OFF)')`
366
- * fix: Bone.bulkCreate() should not throw when called with non attribute (#117)
367
- * fix: batch upsert (#108)
368
- * fix: make sure connection is passed around in all queries carried out within transaction (#105)
369
- * fix: update, sequelize mode get API, destroy compitable (#104)
370
- * fix: `setDataValue` in sequelize adapter should not check prop name strictly
371
- * refactor: spell_insert (#118)
372
- * docs: about egg-orm & migrations (#119)
373
- * docs: revise instructions for installing Jekyll (#111)
374
- * docs: migrations, validations, hooks, and sequelize adapter (#103)
375
- * docs: contributing guides
376
-
377
- 1.3.0 / 2021-03-01
378
- ==================
379
-
380
- * feat: hook support
381
- * feat: dirty check (`changes()` & `previousChanges()`)
382
- * feat: compatible with mysql longtext conversion
383
- * feat: NOT condition
384
-
385
- 1.2.0 / 2020-12-10
386
- ==================
387
-
388
- * feat: `Realm.prototype.transaction()` with async function support
389
- * feat: `Realm.prototype.query()` for raw queries
390
- * feat: `logger.logQuery(sql, duration, { Model, command })`
391
- * feat: `logger.logQueryError(sql, err, duration, { Model, command })`
392
-
393
- 1.1.0 / 2020-11-23
394
- ==================
395
-
396
- * feat: JSON and JSONB data types
397
- * feat: support `stringifyObjects` option for mysql client
398
- * feat: aggregate functions for sequelize adapter
399
- * feat: `Spell.prototype.nodeify()`
400
-
401
- 1.0.3 / 2020-03-16
402
- ==================
403
-
404
- * fix: replace `deep-equal` (which is bloated) with `util.isDeepStrictEqual`
405
-
406
- 1.0.2 / 2020-03-04
407
- ==================
408
-
409
- * fix: driver.alterTable() with multiple columns to add in SQLite
410
-
411
- 1.0.1 / 2020-02-25
412
- ==================
413
-
414
- * fix: bulkCreate in sequelize shim
415
-
416
- 1.0.0 / 2020-02-24
417
- ==================
418
-
419
- First major release. Let's get serious with semver.
420
-
421
- * feat: logger.logQuery(sql, duration) & logger.logQueryError(sql, err)
422
-
423
- 0.5.3 / 2020-02-22
424
- ==================
425
-
426
- * fix: `connect({ sequelize, dialect, client })` to allow mandatory sqlite client
427
- * fix: prevent queries being performed unless model is correctly connected
428
-
429
- 0.5.2 / 2020-02-21
430
- ==================
431
-
432
- * fix: drop the default and unused `require('sqlite3')`
433
-
434
- 0.5.1 / 2020-02-21
435
- ==================
436
-
437
- * fix: `connect({ client: '@journeyapps/sqlcipher' })`
438
-
439
- 0.5.0 / 2020-02-19
440
- ==================
441
-
442
- * feat: `Bone.sync()` to synchronize model with database
443
- * feat: `Bone.createMigrationFile()` to create migration file
444
- * feat: `Bone.migrate()` to run migrations
445
- * feat: `Bone.bulkCreate()` to bulk insert records
446
- * feat: `require('leoric')` now exports `Realm` to connect with multiple databases
447
- * feat: `realm.define()` to define models in an old fashioned way
448
- * feat: `realm.connect()` to connect with database
449
- * feat: SQLite support without hacking node-sqlite3
450
- * feat: `Bone.DataTypes` for type references
451
- * feat: `Bone.init()` to initialize models
452
- * feat: an adaptor to use Leoric in (partially) Sequelize complaint API
453
- * refactor: a complete re-write of JOIN queries
454
- * refactor: added `Bone.driver` to better encapsulate and planish database nuances
455
-
456
- 0.4.5 / 2019-12-14
457
- ==================
458
-
459
- * fix: prevent primary key from being overridden with incorrect `LAST_INSERT_ID()`
460
-
461
- 0.4.4 / 2019-07-15
462
- ==================
463
-
464
- * fix: append default scope when declaring relations, fixes #10
465
-
466
- 0.4.3 / 2019-05-09
467
- ==================
468
-
469
- * fix: prevent Bone.dispatch from creating duplicated records of main table
470
-
471
- 0.4.2 / 2019-04-26
472
- ==================
473
-
474
- * feat: `Spell#orWhere()` and `Spell#orHaving()`
475
- * feat: arithmetic operators
476
- * feat: unary operators such as unary minus `-` and bit invertion `~`
477
- * fix: unset attribute should be overwritable
478
- * fix: `attributeChanged()` should be false if attribute is unset and not overwritten
479
- * fix: subclass with incomplete getter/setter should be complemented
480
- * fix: sharding key validation on `Bone.update()` and `Bone.save()`
481
- * fix: sharding key should be along with primary key on `bone.remove()`
482
- * fix: `Bone.cast()` should leave `null` as is
483
- * fix: `INSERT ... UPDATE` with `id = LAST_INSERT_ID(id)` in MySQL
484
- * fix: `Model.find({ name: { $op1, $op2 } })` object conditions with multiple operators
485
- * fix: prefixing result set with qualifiers if query contains join relations and is not dispatchable
486
- * fix: `Spell#$get(index)` with LIMIT
487
- * doc: `Model.transaction()`
488
- * doc: definition types with `index.d.ts`
489
-
490
- 0.4.1 / 2019-03-21
491
- ==================
492
-
493
- * feat: premature sharding key validation
494
- * fix: output complete SQL instead of parameterized query with values.
495
- * fix: both `connect({ model })` and `connect({ models })` are allowed.
496
- * doc: no more `.findOrCreate()`, just `.upsert()`
497
- * doc: table of contents with kramdown's `{:toc}`
498
- * chore: droped experimental sqlite3 support
499
-
500
- 0.4.0 / 2018-11-05
501
- ==================
502
-
503
- * feat: PostgreSQL support
504
- * feat: Transaction support
505
- * upgrade: (forked) SQLite client updated to SQLite 3.24
506
-
507
-
508
- 0.3.0 / 2018-10-31
509
- ==================
510
-
511
- * feat: SQLite support with a [forked sqlite3](https://github.com/cyjake/node-sqlite3)
512
- * feat: mysql2 support (which is trivial since both mysql and mysql2 share the same API)
513
- * refactor: Spell now formats SQL with the literals separated, which gets escaped by the corresponding client itself later on.
514
-
515
- 0.2.0 / 2018-01-03
516
- ==================
517
-
518
- * breaking: renaming
519
-
520
- 0.1.8 / 2017-12-31
521
- ==================
522
-
523
- * fix: implement `query.batch()` as async iterator
524
- * fix: `NOT (expr)`
525
- * fix: `IFNULL(foo, default)`
526
- * fix: support `.select(name[])`, `.select(name => {})`, and `.select("...name")`
527
- * doc: `Model => className` in association options
528
- * doc: use [jsdoc](http://usejsdoc.org) to generate docs/api
529
- * doc: `.include()`
530
-
531
- 0.1.7 / 2017-12-22
532
- ==================
533
-
534
- * refactor: `{ type: 'op', name: 'as' }` renamed to `{ type: 'alias' }`
535
- * feat: `{ type: 'mod' }` for modifier, currently only `DISTINCT` is recognized
536
- * feat: unary operators like `!` and `NOT`
537
- * feat: `IS` and `IS NOT`
538
- * fix: logic operator precendences
539
- * fix: polymorphic hasMany({ through }) relations
540
- * fix: dispatching multiple results with joins correctly
541
-
542
- 0.1.6 / 2017-12-21
543
- ==================
544
-
545
- * feat: proper `.first`, `.last`, `.all`, and `.get(index)`
546
- * fix: accept `Date`, `boolean`, and `Set` values
547
- * fix: `Model.unscoped`
548
- * fix: `Model.remove({}, true)` should be unscoped
549
-
550
- 0.1.5 / 2017-12-20
551
- ==================
552
-
553
- * refactor: encapsulate column names. Keep them from the users even if the query results can not be dispatched.
554
- * fix: complicated groups with joins should discard the use of subquery.
555
- * fix: camelCase should replace globally
556
- * fix: avoid missing attribtue exception when toJSON/toObject
557
-
558
- 0.1.4 / 2017-12-18
559
- ==================
560
-
561
- * fix: should format condition arrays by hand instead of hand it over to formatExpr
562
- * fix: whereConditions of subquery should retain the order of the whereConditions in major query
563
- * fix: calculated columns should be kept in the final columns when sorting out the attributes
564
- * fix: doesn't depend on co anymore
565
-
566
- 0.1.3 / 2017-12-17
567
- ==================
568
-
569
- * fix: `select distict foo from table`;
570
- * fix: `where (a = 1 or a = 2) and b = 3`;
571
- * doc: a syntax table to provide a better glance over the querying ability.
572
-
573
- 0.1.2 / 2017-12-14
574
- ==================
575
-
576
- * fix: copy left table's orders into subquery to make order/limit work when combined.
577
- * fix: errors should be thrown when accessing attributes that weren't selected at the first place.
578
-
579
- 0.1.1 / 2017-12-13
580
- ==================
581
-
582
- * refactor: automatic versioning on spells. When client calls query methods with chaining, new versions of spell gets duplicated. Makes reuse of spells possible.
583
- * doc: english verion is almost complete <http://cyj.me/leoric>.
584
-
585
- 0.1.0 / 2017-12-09
586
- ==================
587
-
588
- * Initial version, covers basic usage such as model authoring, database connection, query interface, and association.