From 710f8a6aea49b8b5e662676e4e59e17f7e333034 Mon Sep 17 00:00:00 2001 From: Ricardo Gama Date: Mon, 29 Aug 2016 15:34:14 +0100 Subject: [PATCH] Release 1.2.1 --- CHANGELOG.md | 14 +++++++++++++- dist/index.js | 51 +++++++++++++++++++++++++++++++++------------------ package.json | 2 +- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a057d72..71486da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,19 @@ # Changelog -## [1.2.0](https://github.com/seegno/bookshelf-json-columns/tree/HEAD) +## [1.2.1](https://github.com/seegno/bookshelf-json-columns/tree/HEAD) +[Full Changelog](https://github.com/seegno/bookshelf-json-columns/compare/1.2.0...1.2.1) + +**Closed issues:** + +- `array.includes` is undefined in non-ES2015 environments [\#28](https://github.com/seegno/bookshelf-json-columns/issues/28) + +**Merged pull requests:** + +- Update eslint version [\#30](https://github.com/seegno/bookshelf-json-columns/pull/30) ([ricardogama](https://github.com/ricardogama)) +- Add babel-plugin-array-includes [\#29](https://github.com/seegno/bookshelf-json-columns/pull/29) ([ricardogama](https://github.com/ricardogama)) + +## [1.2.0](https://github.com/seegno/bookshelf-json-columns/tree/1.2.0) (2016-08-29) [Full Changelog](https://github.com/seegno/bookshelf-json-columns/compare/1.1.1...1.2.0) **Closed issues:** diff --git a/dist/index.js b/dist/index.js index 6813134..7cda746 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,15 +1,30 @@ - -/** - * Stringify JSON columns. - */ - 'use strict'; -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +var _keys = require('babel-runtime/core-js/object/keys'); + +var _keys2 = _interopRequireDefault(_keys); + +var _extends2 = require('babel-runtime/helpers/extends'); + +var _extends3 = _interopRequireDefault(_extends2); + +var _typeof2 = require('babel-runtime/helpers/typeof'); + +var _typeof3 = _interopRequireDefault(_typeof2); + +var _stringify = require('babel-runtime/core-js/json/stringify'); + +var _stringify2 = _interopRequireDefault(_stringify); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Stringify JSON columns. + */ function stringify(model, attributes, options) { var _this = this; @@ -21,7 +36,7 @@ function stringify(model, attributes, options) { this.jsonColumns.forEach(function (column) { if (_this.attributes[column]) { - _this.attributes[column] = JSON.stringify(_this.attributes[column]); + _this.attributes[column] = (0, _stringify2.default)(_this.attributes[column]); } }); } @@ -49,7 +64,7 @@ function parse(model, response, options) { * Export `bookshelf-json-columns` plugin. */ -exports['default'] = function (Bookshelf) { +exports.default = function (Bookshelf) { var Model = Bookshelf.Model.prototype; var client = Bookshelf.knex.client.config.client; @@ -80,14 +95,14 @@ exports['default'] = function (Bookshelf) { } // Handle arguments as Bookshelf. - var attributes = undefined; + var attributes = void 0; - if (key === null || typeof key === 'object') { + if (key === null || (typeof key === 'undefined' ? 'undefined' : (0, _typeof3.default)(key)) === 'object') { attributes = key || {}; - options = value ? _extends({}, value) : {}; + options = value ? (0, _extends3.default)({}, value) : {}; } else { (attributes = {})[key] = value; - options = options ? _extends({}, options) : {}; + options = options ? (0, _extends3.default)({}, options) : {}; } // Only handle arguments with `patch` option. @@ -96,16 +111,16 @@ exports['default'] = function (Bookshelf) { } // Stringify JSON columns. - Object.keys(attributes).forEach(function (attribute) { - if (_this3.jsonColumns.includes(attribute)) { - attributes[attribute] = JSON.stringify(attributes[attribute]); + (0, _keys2.default)(attributes).forEach(function (attribute) { + if (_this3.jsonColumns.indexOf(attribute) !== -1) { + attributes[attribute] = (0, _stringify2.default)(attributes[attribute]); } }); return Model.save.call(this, attributes, options).then(function (model) { // Parse JSON columns. - Object.keys(attributes).forEach(function (attribute) { - if (_this3.jsonColumns.includes(attribute)) { + (0, _keys2.default)(attributes).forEach(function (attribute) { + if (_this3.jsonColumns.indexOf(attribute) !== -1) { model.attributes[attribute] = JSON.parse(model.attributes[attribute]); } }); diff --git a/package.json b/package.json index 6e55ce2..8f4fdae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bookshelf-json-columns", - "version": "1.2.0", + "version": "1.2.1", "description": "Parse JSON columns with Bookshelf.js", "license": "MIT", "author": {