@knorm/knorm
Advanced tools
Comparing version 1.3.0 to 1.4.1
258
CHANGELOG.md
@@ -0,5 +1,37 @@ | ||
<a name="1.4.1"></a> | ||
## [1.4.1](https://github.com/knorm/knorm/compare/v1.2.1...v1.4.1) (2018-08-15) | ||
### Features | ||
* **Query:** add support for `FOR UPDATE OF` | ||
```js | ||
Model.fetch({ forUpdate: true, of: ['table'] }); | ||
Model.query.forUpdate().of('table').fetch(); | ||
``` | ||
<a name="1.4.0"></a> | ||
## [1.4.0](https://github.com/knorm/knorm/compare/v1.2.1...v1.4.0) (2018-08-15) | ||
### VERSION DELETED | ||
<a name="1.3.0"></a> | ||
## [1.3.0](https://github.com/knorm/knorm/compare/v1.2.1...v1.3.0) (2018-08-13) | ||
### Features | ||
* support configuring a model's schema name | ||
```js | ||
Model.schema = 'schema'; | ||
Model.table = 'table'; | ||
``` | ||
<a name="1.2.1"></a> | ||
## [1.2.1](https://github.com/knorm/knorm/compare/v1.2.0...v1.2.1) (2018-08-07) | ||
### Bug Fixes | ||
@@ -9,8 +41,6 @@ | ||
<a name="1.2.0"></a> | ||
<a name="1.2.0"></a> | ||
# [1.2.0](https://github.com/knorm/knorm/compare/v1.1.0...v1.2.0) (2018-07-30) | ||
### Features | ||
@@ -21,8 +51,6 @@ | ||
<a name="1.1.0"></a> | ||
<a name="1.1.0"></a> | ||
# [1.1.0](https://github.com/knorm/knorm/compare/v1.0.1...v1.1.0) (2018-07-26) | ||
### Features | ||
@@ -32,8 +60,6 @@ | ||
<a name="1.0.1"></a> | ||
<a name="1.0.1"></a> | ||
## [1.0.1](https://github.com/knorm/knorm/compare/v1.0.0...v1.0.1) (2018-07-05) | ||
### Bug Fixes | ||
@@ -43,13 +69,10 @@ | ||
<a name="1.0.0"></a> | ||
<a name="1.0.0"></a> | ||
# [1.0.0](https://github.com/knorm/knorm/compare/v1.0.0-next...v1.0.0) (2018-06-27) | ||
<a name="1.0.0-next"></a> | ||
<a name="1.0.0-next"></a> | ||
# [1.0.0-next](https://github.com/knorm/knorm/compare/v0.11.1...v1.0.0-next) (2018-06-27) | ||
### Bug Fixes | ||
@@ -71,3 +94,3 @@ | ||
* **Query:** cast before validate ([dc6a851](https://github.com/knorm/knorm/commit/dc6a851)), closes [#fb394f3](https://github.com/knorm/knorm/issues/fb394f3) | ||
* **Query:** cast values *after* validating ([d222922](https://github.com/knorm/knorm/commit/d222922)) | ||
* **Query:** cast values _after_ validating ([d222922](https://github.com/knorm/knorm/commit/d222922)) | ||
* **Query:** change default placeholder to `$` ([414fda0](https://github.com/knorm/knorm/commit/414fda0)) | ||
@@ -89,3 +112,2 @@ * **Query:** do not consider primary field for array updates ([b12be78](https://github.com/knorm/knorm/commit/b12be78)) | ||
### Code Refactoring | ||
@@ -106,3 +128,2 @@ | ||
### Features | ||
@@ -131,3 +152,2 @@ | ||
### Performance Improvements | ||
@@ -140,3 +160,2 @@ | ||
### BREAKING CHANGES | ||
@@ -148,7 +167,7 @@ | ||
db connection-handling to plugins | ||
* `const { Model } = require('@knorm/knorm')` does not work anymore. base | ||
* `const { Model } = require('@knorm/knorm')` does not work anymore. base | ||
classes can be accessed via a Knorm instance or as Knorm statics | ||
* plugins are now required to have a `name` property | ||
**Model:** | ||
**Model:** | ||
@@ -164,3 +183,3 @@ * refactored: | ||
* `Model.getUnique` => `Model.config.unique` / `Model.unique` setter | ||
* `Model.getReferences` => `Model.config.references` / `Model.references` getter | ||
* `Model.getReferences` => `Model.config.references` / `Model.references` getter | ||
* `Model.getNotUpdated` => `Model.config.notUpdated` / `Model.notUpdated` getter | ||
@@ -183,3 +202,3 @@ | ||
**Field:** | ||
**Field:** | ||
@@ -192,7 +211,7 @@ * renamed field types: | ||
**Virtual:** | ||
**Virtual:** | ||
* removed `hasGetter` and `hasSetter` instead, use `!!virtual.get` or `!!virtual.set` | ||
**Query:** | ||
**Query:** | ||
@@ -204,3 +223,3 @@ * swap knex with sql-bricks. this change means that knorm only | ||
tested anyway | ||
* support for relations moved to @knorm/relations: | ||
* support for relations moved to @knorm/relations: | ||
https://github.com/knorm/relations | ||
@@ -214,3 +233,3 @@ * removed Query.prototype.count, moved to @knorm/paginate: | ||
knex's query builder: `.fields({ field: 'alias' })` | ||
to `.fields({ alias: 'field' })` | ||
to `.fields({ alias: 'field' })` | ||
* removed `Query.errors` and added them directly to `Query` | ||
@@ -255,7 +274,6 @@ * all `where*` e.g. `whereIn` are removed and replaced with | ||
<a name="0.11.1"></a> | ||
<a name="0.11.1"></a> | ||
## [0.11.1](https://github.com/joelmukuthu/knorm/compare/v0.11.0...v0.11.1) (2018-05-02) | ||
### Bug Fixes | ||
@@ -266,8 +284,6 @@ | ||
<a name="0.11.0"></a> | ||
<a name="0.11.0"></a> | ||
# [0.11.0](https://github.com/joelmukuthu/knorm/compare/v0.10.1...v0.11.0) (2017-12-29) | ||
### Code Refactoring | ||
@@ -277,3 +293,2 @@ | ||
### Features | ||
@@ -283,3 +298,2 @@ | ||
### BREAKING CHANGES | ||
@@ -306,8 +320,6 @@ | ||
<a name="0.10.1"></a> | ||
<a name="0.10.1"></a> | ||
## [0.10.1](https://github.com/joelmukuthu/knorm/compare/v0.10.0...v0.10.1) (2017-12-28) | ||
### Features | ||
@@ -317,8 +329,6 @@ | ||
<a name="0.10.0"></a> | ||
<a name="0.10.0"></a> | ||
# [0.10.0](https://github.com/joelmukuthu/knorm/compare/v0.9.3...v0.10.0) (2017-12-23) | ||
### Bug Fixes | ||
@@ -330,3 +340,2 @@ | ||
### Code Refactoring | ||
@@ -339,3 +348,2 @@ | ||
### Features | ||
@@ -350,3 +358,2 @@ | ||
### BREAKING CHANGES | ||
@@ -356,4 +363,4 @@ | ||
* **Model:** previously, the primary field was assumed to be | ||
one of the fields that should not be updated by `Query.prototype.update`, now it | ||
has to be specified: | ||
one of the fields that should not be updated by `Query.prototype.update`, now it | ||
has to be specified: | ||
@@ -365,7 +372,9 @@ ```js | ||
``` | ||
* **Model:** ```js | ||
Model.fetchById => Model.fetchByPrimaryField | ||
Model.updateById => Model.updateByPrimaryField | ||
Model.deleteById => Model.deleteByPrimaryField | ||
``` | ||
Model.fetchById => Model.fetchByPrimaryField | ||
Model.updateById => Model.updateByPrimaryField | ||
Model.deleteById => Model.deleteByPrimaryField | ||
```` | ||
* **Model:** instead of using the `fieldNames` config to define | ||
@@ -378,9 +387,8 @@ the primary field, use the `primary` Field config: | ||
}; | ||
``` | ||
```` | ||
<a name="0.9.3"></a> | ||
<a name="0.9.3"></a> | ||
## [0.9.3](https://github.com/joelmukuthu/knorm/compare/v0.9.2...v0.9.3) (2017-11-23) | ||
### Bug Fixes | ||
@@ -392,3 +400,2 @@ | ||
### Features | ||
@@ -398,8 +405,6 @@ | ||
<a name="0.9.2"></a> | ||
<a name="0.9.2"></a> | ||
## [0.9.2](https://github.com/joelmukuthu/knorm/compare/v0.9.1...v0.9.2) (2017-11-16) | ||
### Bug Fixes | ||
@@ -409,8 +414,6 @@ | ||
<a name="0.9.1"></a> | ||
<a name="0.9.1"></a> | ||
## [0.9.1](https://github.com/joelmukuthu/knorm/compare/v0.9.0...v0.9.1) (2017-11-01) | ||
### Bug Fixes | ||
@@ -420,8 +423,6 @@ | ||
<a name="0.9.0"></a> | ||
<a name="0.9.0"></a> | ||
# [0.9.0](https://github.com/joelmukuthu/knorm/compare/v0.8.1...v0.9.0) (2017-11-01) | ||
### Bug Fixes | ||
@@ -440,3 +441,2 @@ | ||
### Features | ||
@@ -446,8 +446,6 @@ | ||
<a name="0.8.1"></a> | ||
<a name="0.8.1"></a> | ||
## [0.8.1](https://github.com/joelmukuthu/knorm/compare/v0.8.0...v0.8.1) (2017-10-06) | ||
### Features | ||
@@ -457,8 +455,6 @@ | ||
<a name="0.8.0"></a> | ||
<a name="0.8.0"></a> | ||
# [0.8.0](https://github.com/joelmukuthu/knorm/compare/v0.7.3...v0.8.0) (2017-10-05) | ||
### Code Refactoring | ||
@@ -468,3 +464,2 @@ | ||
### Features | ||
@@ -474,17 +469,14 @@ | ||
### BREAKING CHANGES | ||
* **Query:** to conform with other Query methods, update now | ||
always resolves with an array. If passed an instance with an id, | ||
it no longer adds the "where id" clause, this has instead moved | ||
to Model.prototype.update (similar to Model.prototype.fetch and | ||
Model.prototype.delete) | ||
always resolves with an array. If passed an instance with an id, | ||
it no longer adds the "where id" clause, this has instead moved | ||
to Model.prototype.update (similar to Model.prototype.fetch and | ||
Model.prototype.delete) | ||
<a name="0.7.3"></a> | ||
<a name="0.7.3"></a> | ||
## [0.7.3](https://github.com/joelmukuthu/knorm/compare/v0.7.2...v0.7.3) (2017-10-04) | ||
### Bug Fixes | ||
@@ -495,8 +487,6 @@ | ||
<a name="0.7.2"></a> | ||
<a name="0.7.2"></a> | ||
## [0.7.2](https://github.com/joelmukuthu/knorm/compare/v0.7.1...v0.7.2) (2017-09-05) | ||
### Bug Fixes | ||
@@ -509,3 +499,2 @@ | ||
### Features | ||
@@ -517,8 +506,6 @@ | ||
<a name="0.7.1"></a> | ||
<a name="0.7.1"></a> | ||
## [0.7.1](https://github.com/joelmukuthu/knorm/compare/v0.7.0...v0.7.1) (2017-08-30) | ||
### Bug Fixes | ||
@@ -528,8 +515,6 @@ | ||
<a name="0.7.0"></a> | ||
<a name="0.7.0"></a> | ||
# [0.7.0](https://github.com/joelmukuthu/knorm/compare/v0.6.2...v0.7.0) (2017-08-30) | ||
### Bug Fixes | ||
@@ -541,3 +526,2 @@ | ||
### Code Refactoring | ||
@@ -548,3 +532,2 @@ | ||
### Features | ||
@@ -562,9 +545,9 @@ | ||
### BREAKING CHANGES | ||
* **Query:** before, Query was casting models before validation, | ||
which meant that the value passed to custom validators would already | ||
be cast. this change might require custom validators to be updated. | ||
which meant that the value passed to custom validators would already | ||
be cast. this change might require custom validators to be updated. | ||
* **Field:** refactored: | ||
- Field.prototype.setModel to Field.prototype.updateModel | ||
@@ -574,2 +557,3 @@ - Virtual.prototype.setModel to Virtual.prototype.updateModel | ||
removed Field.prototype.setReference | ||
* **Field:** field cast options changed from: | ||
@@ -601,8 +585,6 @@ | ||
<a name="0.6.2"></a> | ||
<a name="0.6.2"></a> | ||
## [0.6.2](https://github.com/joelmukuthu/knorm/compare/v0.6.1...v0.6.2) (2017-08-18) | ||
### Features | ||
@@ -613,8 +595,6 @@ | ||
<a name="0.6.1"></a> | ||
<a name="0.6.1"></a> | ||
## [0.6.1](https://github.com/joelmukuthu/knorm/compare/v0.6.0...v0.6.1) (2017-08-16) | ||
### Features | ||
@@ -625,11 +605,8 @@ | ||
<a name="0.6.0"></a> | ||
<a name="0.6.0"></a> | ||
# [0.6.0](https://github.com/joelmukuthu/knorm/compare/v0.5.0...v0.6.0) (2017-08-11) | ||
* feat(field) support customizing validation errors ([4d6dcca](https://github.com/joelmukuthu/knorm/commit/4d6dcca)) | ||
### Bug Fixes | ||
@@ -639,3 +616,2 @@ | ||
### Code Refactoring | ||
@@ -645,19 +621,16 @@ | ||
### BREAKING CHANGES | ||
* **Query:** QueryError arguments have changed and KnormError | ||
does not auto-format messages anymore due to: | ||
- removed Field.errors in place of only Field.ValidationError | ||
- changed ValidationError arguments | ||
does not auto-format messages anymore due to: | ||
* removed Field.errors in place of only Field.ValidationError | ||
* changed ValidationError arguments | ||
* Field.prototype.cast/Model.prototype.cast options are changed: | ||
- options.save => options.forSave | ||
- options.fetch => options.forFetch | ||
* options.save => options.forSave | ||
* options.fetch => options.forFetch | ||
<a name="0.5.0"></a> | ||
<a name="0.5.0"></a> | ||
# [0.5.0](https://github.com/joelmukuthu/knorm/compare/v0.4.2...v0.5.0) (2017-08-08) | ||
### Features | ||
@@ -667,13 +640,10 @@ | ||
### BREAKING CHANGES | ||
* **Field:** Field.prototype.hasCast refactored to Field.prototype._hasCast | ||
* **Field:** Field.prototype.hasCast refactored to Field.prototype.\_hasCast | ||
<a name="0.4.2"></a> | ||
<a name="0.4.2"></a> | ||
## [0.4.2](https://github.com/joelmukuthu/knorm/compare/v0.4.1...v0.4.2) (2017-08-08) | ||
### Features | ||
@@ -683,8 +653,6 @@ | ||
<a name="0.4.1"></a> | ||
<a name="0.4.1"></a> | ||
## [0.4.1](https://github.com/joelmukuthu/knorm/compare/v0.4.0...v0.4.1) (2017-08-04) | ||
### Bug Fixes | ||
@@ -694,3 +662,2 @@ | ||
### Features | ||
@@ -700,8 +667,6 @@ | ||
<a name="0.4.0"></a> | ||
<a name="0.4.0"></a> | ||
# [0.4.0](https://github.com/joelmukuthu/knorm/compare/v0.3.0...v0.4.0) (2017-08-03) | ||
### Bug Fixes | ||
@@ -711,3 +676,2 @@ | ||
### Code Refactoring | ||
@@ -718,3 +682,2 @@ | ||
### Features | ||
@@ -724,3 +687,2 @@ | ||
### BREAKING CHANGES | ||
@@ -731,8 +693,6 @@ | ||
<a name="0.3.0"></a> | ||
<a name="0.3.0"></a> | ||
# [0.3.0](https://github.com/joelmukuthu/knorm/compare/v0.2.4...v0.3.0) (2017-07-28) | ||
### Code Refactoring | ||
@@ -742,14 +702,11 @@ | ||
### BREAKING CHANGES | ||
* **Query:** removed Query.prototype.with and changed Query.prototype.join | ||
to do an inner join query | ||
to do an inner join query | ||
<a name="0.2.4"></a> | ||
<a name="0.2.4"></a> | ||
## [0.2.4](https://github.com/joelmukuthu/knorm/compare/v0.2.3...v0.2.4) (2017-07-28) | ||
### Bug Fixes | ||
@@ -759,8 +716,6 @@ | ||
<a name="0.2.3"></a> | ||
<a name="0.2.3"></a> | ||
## [0.2.3](https://github.com/joelmukuthu/knorm/compare/v0.2.2...v0.2.3) (2017-07-27) | ||
### Bug Fixes | ||
@@ -770,8 +725,6 @@ | ||
<a name="0.2.2"></a> | ||
<a name="0.2.2"></a> | ||
## [0.2.2](https://github.com/joelmukuthu/knorm/compare/v0.2.1...v0.2.2) (2017-07-27) | ||
### Bug Fixes | ||
@@ -781,3 +734,2 @@ | ||
### Features | ||
@@ -787,8 +739,6 @@ | ||
<a name="0.2.1"></a> | ||
<a name="0.2.1"></a> | ||
## [0.2.1](https://github.com/joelmukuthu/knorm/compare/v0.2.0...v0.2.1) (2017-07-26) | ||
### Bug Fixes | ||
@@ -800,3 +750,2 @@ | ||
### Features | ||
@@ -807,8 +756,6 @@ | ||
<a name="0.2.0"></a> | ||
<a name="0.2.0"></a> | ||
# [0.2.0](https://github.com/joelmukuthu/knorm/compare/v0.1.0...v0.2.0) (2017-07-21) | ||
### Bug Fixes | ||
@@ -818,3 +765,2 @@ | ||
### Features | ||
@@ -825,8 +771,6 @@ | ||
<a name="0.1.0"></a> | ||
<a name="0.1.0"></a> | ||
# [0.1.0](https://github.com/joelmukuthu/knorm/compare/v0.0.2...v0.1.0) (2017-06-05) | ||
### Bug Fixes | ||
@@ -838,3 +782,2 @@ | ||
### Features | ||
@@ -850,5 +793,4 @@ | ||
<a name="0.0.2"></a> | ||
<a name="0.0.2"></a> | ||
## 0.0.2 (2017-03-20) |
@@ -59,2 +59,6 @@ ## Query.knex | ||
## Query.prototype.forUpdate() : Query | ||
## Query.prototype.of(tables) : Query | ||
## Query.prototype.leftJoin(queries, [options]) : Query | ||
@@ -61,0 +65,0 @@ |
@@ -70,2 +70,13 @@ const { difference } = require('lodash'); | ||
appendOption(option, value) { | ||
if (!isArray(value)) { | ||
value = [value]; | ||
} | ||
this.options[option] = this.options[option] || []; | ||
this.options[option] = this.options[option].concat(...value); | ||
return this; | ||
} | ||
debug(debug = true) { | ||
@@ -155,15 +166,14 @@ return this.setOption('debug', !!debug); | ||
// TODO: support and test this | ||
// forUpdate(...forUpdate) { | ||
// return this.setOption('forUpdate', forUpdate); | ||
// } | ||
forUpdate() { | ||
return this.setOption('forUpdate', true); | ||
} | ||
// TODO: support and test this | ||
// of(...args) { | ||
// return this.addOption('of', args); | ||
// } | ||
of(...tables) { | ||
return this.appendOption('of', tables); | ||
} | ||
// TODO: support and test this | ||
// noWait(...noWait) { | ||
// return this.setOption('noWait', noWait); | ||
// TODO: support and test `noWait` | ||
// mostly pending https://github.com/Suor/sql-bricks-postgres/issues/15 | ||
// noWait() { | ||
// return this.setOption('noWait', true); | ||
// } | ||
@@ -404,21 +414,33 @@ | ||
['where', 'having', 'groupBy', 'orderBy'].forEach(option => { | ||
const values = this.options[option]; | ||
if (values) { | ||
values.forEach(value => { | ||
switch (option) { | ||
case 'where': | ||
return this.prepareWhere(sql, value); | ||
Object.entries(this.options).forEach(([option, values]) => { | ||
if (!values) { | ||
return; | ||
} | ||
case 'having': | ||
return this.prepareHaving(sql, value); | ||
if (option === 'forUpdate') { | ||
return sql.forUpdate(); | ||
} | ||
case 'groupBy': | ||
return this.prepareGroupBy(sql, value); | ||
if (!values.length) { | ||
return; | ||
} | ||
case 'orderBy': | ||
return this.prepareOrderBy(sql, value); | ||
} | ||
}); | ||
} | ||
values.forEach(value => { | ||
switch (option) { | ||
case 'of': | ||
return sql.of(this.quote(value)); | ||
case 'where': | ||
return this.prepareWhere(sql, value); | ||
case 'having': | ||
return this.prepareHaving(sql, value); | ||
case 'groupBy': | ||
return this.prepareGroupBy(sql, value); | ||
case 'orderBy': | ||
return this.prepareOrderBy(sql, value); | ||
} | ||
}); | ||
}); | ||
@@ -425,0 +447,0 @@ |
{ | ||
"name": "@knorm/knorm", | ||
"version": "1.3.0", | ||
"version": "1.4.1", | ||
"description": "A purely ES6 class-based ORM for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
431662
9809