Skip to content

Commit

Permalink
Release 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsoares committed Nov 11, 2016
1 parent f016f18 commit 14162a8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [2.0.1](https://github.com/seegno/bookshelf-json-columns/tree/2.0.1) (2016-11-11)
[Full Changelog](https://github.com/seegno/bookshelf-json-columns/compare/2.0.0...2.0.1)

**Closed issues:**

- model.refresh is not working properly | bug [\#42](https://github.com/seegno/bookshelf-json-columns/issues/42)
- Malformed array literal [\#41](https://github.com/seegno/bookshelf-json-columns/issues/41)

**Merged pull requests:**

- Add user to postgres knexfile [\#44](https://github.com/seegno/bookshelf-json-columns/pull/44) ([ricardogama](https://github.com/ricardogama))
- Fix parsing on saving through query [\#43](https://github.com/seegno/bookshelf-json-columns/pull/43) ([ricardogama](https://github.com/ricardogama))

## [2.0.0](https://github.com/seegno/bookshelf-json-columns/tree/2.0.0) (2016-10-25)
[Full Changelog](https://github.com/seegno/bookshelf-json-columns/compare/1.2.2...2.0.0)

Expand Down
15 changes: 13 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ function stringify(model, attributes, options) {
return;
}

// Mark json columns as stringfied.
options.parseJsonColumns = true;

this.constructor.jsonColumns.forEach(column => {
if (this.attributes[column]) {
this.attributes[column] = JSON.stringify(this.attributes[column]);
Expand All @@ -27,9 +30,17 @@ function stringify(model, attributes, options) {
* Parse JSON columns.
*/

function parse(model, response, options) {
function parse(model, response) {
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

// Do not parse with `patch` option.
if (options && options.patch) {
if (options.patch) {
return;
}

// Do not parse on `fetched` event after saving.
// eslint-disable-next-line no-underscore-dangle
if (!options.parseJsonColumns && options.query && options.query._method !== 'select') {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bookshelf-json-columns",
"version": "2.0.0",
"version": "2.0.1",
"description": "Parse JSON columns with Bookshelf.js",
"license": "MIT",
"author": {
Expand Down

0 comments on commit 14162a8

Please sign in to comment.