Comparing version 5.7.4 to 5.7.5
@@ -5,2 +5,13 @@ # Change Log | ||
<a name="5.7.5"></a> | ||
## [5.7.5](https://github.com/dmfay/massive-js/compare/v5.7.4...v5.7.5) (2019-02-06) | ||
### Bug Fixes | ||
* cache and restore custom pg-promise receive option ([#665](https://github.com/dmfay/massive-js/issues/665)) ([f70847f](https://github.com/dmfay/massive-js/commit/f70847f)) | ||
* **package:** update pg-promise to version 8.5.5 ([489f443](https://github.com/dmfay/massive-js/commit/489f443)) | ||
<a name="5.7.4"></a> | ||
@@ -7,0 +18,0 @@ ## [5.7.4](https://github.com/dmfay/massive-js/compare/v5.7.3...v5.7.4) (2019-01-25) |
@@ -10,6 +10,8 @@ # Persistence | ||
* [save](#save) | ||
* [Restrictions](#restrictions) | ||
* [Options](#options) | ||
* [insert](#insert) | ||
* [Multiple Records](#multiple-records) | ||
* [Deep Insert](#deep-insert) | ||
* [Options](#options) | ||
* [Options](#options-1) | ||
* [update](#update) | ||
@@ -22,6 +24,11 @@ * [destroy](#destroy) | ||
`save` persists a single object to the database. On initialization, Massive records your tables' primary key information and uses this to determine whether the object passed to `save` represents a new or an existing row and invokes `insert` or `update` appropriately. The promise `save` returns will resolve to the created or modified record represented as an object. | ||
`save` persists a single object to the database. On initialization, Massive records your tables' primary key information and uses this to determine whether the object passed to `save` represents a new or an existing row and invokes `insert` or `update` appropriately. **This means it is not a true upsert, and that some care must be taken with its use in certain situations!** The promise `save` returns will resolve to the created or modified record represented as an object. | ||
`save` may not be used with foreign tables or updatable views, since they cannot have primary keys. If you need to persist data to a foreign table or updatable view, use `insert` and `update`. | ||
### Restrictions | ||
* `save` may not be used with foreign tables or updatable views, since they cannot have primary keys. If you need to persist data to a foreign table or updatable view, use `insert` and `update`. | ||
* `save` should generally be avoided if your table's primary key does not include at least one column sourced from a sequence or function (eg an auto-incrementing integer or one of the UUID-generating functions). If you are trying to create a record and your table definition requires you to specify values for all primary key columns, you _must_ use `insert`; `save` is effectively an `update` in this scenario. | ||
### Options | ||
[Query options](options) valid for `insert`, and for results processing, may be used with `save` as a second argument. However, most of these are of limited utility. | ||
@@ -28,0 +35,0 @@ |
@@ -204,2 +204,9 @@ 'use strict'; | ||
// cache pg-promise receive option config | ||
let receiveOptionCached; | ||
if (this.instance.$config && this.instance.$config.options) { | ||
receiveOptionCached = this.instance.$config.options.receive; | ||
delete this.instance.$config.options.receive; | ||
} | ||
const initPromises = [ | ||
@@ -276,2 +283,8 @@ // get the current schema; this is usually 'public' unless someone | ||
// restore pg-promise receive option config | ||
// eslint-disable-next-line no-extra-boolean-cast | ||
if (!!receiveOptionCached) { | ||
this.instance.$config.options.receive = receiveOptionCached; | ||
} | ||
return this; | ||
@@ -278,0 +291,0 @@ }); |
{ | ||
"name": "massive", | ||
"version": "5.7.4", | ||
"version": "5.7.5", | ||
"description": "A small query tool for Postgres that embraces json and makes life simpler", | ||
@@ -65,3 +65,3 @@ "homepage": "https://dmfay.github.io/massive-js/", | ||
"lodash": "4.17.11", | ||
"pg-promise": "8.5.4", | ||
"pg-promise": "8.5.5", | ||
"pg-query-stream": "2.0.0" | ||
@@ -77,3 +77,3 @@ }, | ||
"mocha": "5.2.0", | ||
"nyc": "12.0.2", | ||
"nyc": "13.2.0", | ||
"standard-version": "4.4.0" | ||
@@ -80,0 +80,0 @@ }, |
219413
8216
2484
+ Addedpg@7.8.0(transitive)
+ Addedpg-int8@1.0.1(transitive)
+ Addedpg-promise@8.5.5(transitive)
+ Addedpg-types@2.0.1(transitive)
+ Addedpostgres-array@2.0.0(transitive)
- Removedpg@7.7.1(transitive)
- Removedpg-promise@8.5.4(transitive)
- Removedpg-types@1.12.1(transitive)
- Removedpostgres-array@1.0.3(transitive)
Updatedpg-promise@8.5.5