Socket
Socket
Sign inDemoInstall

bookshelf

Package Overview
Dependencies
Maintainers
7
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf - npm Package Compare versions

Comparing version 0.12.0 to 0.12.1

16

.github/ISSUE_TEMPLATE.md

@@ -1,3 +0,1 @@

# Issue name
* Related Issues: _#IssueNumber if necessary_

@@ -7,21 +5,21 @@

A short description of what the features or the bugs are. Try to keep it simple and within a
single-paragraph.
_A short description of what the features or the bugs are. Try to keep it simple and within a single-paragraph._
## Issue Description
Describe the bug found or the feature that you are proposing.
_Describe the bug found or the feature that you are proposing._
If it's completely new feature explain why this new functionality is necessary, and propose some advice for the development (or just open a Pull Request if you have already started to work on the feature on your own).
_If it's completely new feature explain why this new functionality is necessary, and propose some advice for the
development, or just open a Pull Request if you have already started to work on the feature on your own._
## Steps to reproduce issue
If the bug is complex to describe, show how developers can reproduce it (using code snippet, database data, etc...) and describe its drawbacks.
_If the bug is complex to describe, show how developers can reproduce it using code snippet, database data, etc..._
## Expected behaviour
Explain what is the expected behaviour of a program while using the code related to this issue.
_What is the behaviour that you were expecting after following the steps outlined above?_
## Actual behaviour
Explain what is the actual behaviour of a program and what are the actual errors while running the affected code.
_What behaviour did you get instead?_

@@ -1,3 +0,1 @@

# PR name
* Related Issues: _#IssueNumber if necessary_

@@ -8,26 +6,22 @@ * Previous PRs: _#PRNumber if this PR is a follow-up_

A short description of what the feature or the bug-fix is. Try to keep it to a
single-paragraph "elevator pitch" so the reader understands what
problem this proposal is addressing.
_A short description of what the feature or the bug-fix is. Try to keep it to a single paragraph "elevator pitch" style
so the reader easily understands what problem this proposal is addressing._
## Motivation
Describe the problems that this proposal seeks to address. If the
problem is that some common pattern is currently hard to express, show
how one can currently get a similar effect and describe its
drawbacks. If it's completely new functionality that cannot be
emulated, motivate why this new functionality is necessary.
_Describe the problems that this proposal seeks to address and why it's important. If it's completely new functionality
explain why this new functionality is necessary._
## Proposed solution
Describe your solution to the problem. Provide examples and describe
how they work. Show why your solution is better than current
workarounds: is it cleaner, safer, or more efficient?
_Describe your solution to the problem. If possible provide examples and describe how they work. Show why your solution
is better than what's currently available: is it cleaner, safer, or more efficient?_
## Current PR Issues
If present describe some issues in the Pull Request, in order to help others in the full development of the PR.
_Are there any known issues in this Pull Request? This will help others understand if more work will be needed._
## Alternatives considered
Describe alternative approaches to addressing the same problem, and why you chose this approach instead.
_Describe any alternative approaches to addressing the same problem that you have thought about, and why you chose this
approach instead._
## Change Log
**0.12.1** <small>_Jan 8, 2018_</small> - [Diff](https://github.com/bookshelf/bookshelf/compare/0.12.0...0.12.1)
- Lots of documentation fixes and updates:
- Fix incorrect value of second argument to model event handlers: [#1723](https://github.com/bookshelf/bookshelf/pull/1723)
- Fix incorrect return value from `.detach()`: [#1720](https://github.com/bookshelf/bookshelf/pull/1720)
- Fix incorrect return value from `model.has()`: [#1712](https://github.com/bookshelf/bookshelf/pull/1712)
- Fix `fetching:collection` and `fetched:collection` not being generated or visible on the navigation bar: [#1114](https://github.com/bookshelf/bookshelf/pull/1114)
- Update contributing document and issue templates: [#1736](https://github.com/bookshelf/bookshelf/pull/1736)
- Add more information and links to Parse and Format docs: [#1727](https://github.com/bookshelf/bookshelf/pull/1727)
- Add bookshelf-ez-fetch to Community Plugins: [#1708](https://github.com/bookshelf/bookshelf/pull/1708)
- Add bookshelf-default-select to Community Plugins: [#1706](https://github.com/bookshelf/bookshelf/pull/1706)
- Add information and examples about calling `super()` on model's `initialize()`: [#1529](https://github.com/bookshelf/bookshelf/pull/1529)
- Add npm version badge to readme: [f4dd792](https://github.com/bookshelf/bookshelf/commit/f4dd79267ad8267a7073dd5c9f0661f6591ae96f)
- Fix inability to attach belongsToMany relation to models fetched with `fetchAll()`: [#1716](https://github.com/bookshelf/bookshelf/pull/1716)
- Fix foreign key = 0 not fetching related object: [#1639](https://github.com/bookshelf/bookshelf/pull/1639)
- Fix unparsed `previousAttributes` for related models: [#1457](https://github.com/bookshelf/bookshelf/pull/1457)
- Update some dependencies: [#1734](https://github.com/bookshelf/bookshelf/pull/1734), [#1733](https://github.com/bookshelf/bookshelf/pull/1733), [#1732](https://github.com/bookshelf/bookshelf/pull/1732), [#1728](https://github.com/bookshelf/bookshelf/pull/1728), [#1726](https://github.com/bookshelf/bookshelf/pull/1726)
**0.12.0** <small>_Nov 27, 2017_</small> - [Diff](https://github.com/bookshelf/bookshelf/compare/0.11.1...0.12.0)
**User-Facing**
- Skip visibility-plugin `hidden` and `visible` attributes [#1699](https://github.com/bookshelf/bookshelf/pull/1699).

@@ -10,4 +27,2 @@ - Used w/ `<model>.toJSON({ visibility: false })`

- Documentation typo fixes [#1693](https://github.com/bookshelf/bookshelf/pull/1693).
**Dev-Facing**
- Now caching `node_modules` to speed up travis-ci builds [#1695](https://github.com/bookshelf/bookshelf/pull/1695).

@@ -17,4 +32,2 @@ - Use Docker containers for test runs [#1674](https://github.com/bookshelf/bookshelf/pull/1674).

**0.11.1** <small>_Nov 15, 2017_</small> — [Diff](https://github.com/bookshelf/bookshelf/compare/0.11.0...0.11.1)

@@ -21,0 +34,0 @@

@@ -110,3 +110,12 @@ 'use strict';

* @description
* Custom initialization function.
* Called by the {@link Collection Collection constructor} when creating a new instance.
* Override this function to add custom initialization, such as event listeners.
* Because plugins may override this method in subclasses, make sure to call
* your super (extended) class. e.g.
*
* initialize: function() {
* this.constructor.__super__.initialize.apply(this, arguments);
* // Your initialization code ...
* }
*
* @see Collection

@@ -113,0 +122,0 @@ */

@@ -99,3 +99,10 @@ 'use strict';

* Override this function to add custom initialization, such as event listeners.
* Because plugins may override this method in subclasses, make sure to call
* your super (extended) class. e.g.
*
* initialize: function() {
* this.constructor.__super__.initialize.apply(this, arguments);
* // Your initialization code ...
* }
*
* @see Model

@@ -138,5 +145,5 @@ *

*
* If the table you're working with does not have an Primary-Key in the form
* of a single column - you'll have to override it with a getter that returns
* null. (overriding with undefined does not cascade the default behavior of
* If the table you're working with does not have an Primary-Key in the form
* of a single column - you'll have to override it with a getter that returns
* null. (overriding with undefined does not cascade the default behavior of
* the value `'id'`.

@@ -352,3 +359,3 @@ * Such a getter in ES6 would look like `get idAttribute() { return null }`

* @param {string} attribute The attribute to check.
* @returns {bool} True if `attribute` is set, otherwise null.
* @returns {bool} True if `attribute` is set, otherwise `false`.
*/

@@ -363,5 +370,5 @@ ModelBase.prototype.has = function (attr) {

*
* The parse method is called whenever a {@link Model model}'s data is returned
* in a {@link Model#fetch fetch} call. The function is passed the raw database
* response object, and should return the {@link Model#attributes
* The `parse` method is called whenever a {@link Model model}'s data is
* returned in a {@link Model#fetch fetch} call. The function is passed the raw
* database response object, and should return the {@link Model#attributes
* attributes} hash to be {@link Model#set set} on the model. The default

@@ -375,2 +382,6 @@ * implementation is a no-op, simply passing through the JSON response.

*
* If you need to format your data before it is saved to the database, override
* the {@link Model#format format} method in your models. That method does the
* opposite operation of `parse`.
*
* @example

@@ -431,2 +442,13 @@ *

*
* Do note that `format` is used to modify the state of the model when
* accessing the database, so if you remove an attribute in your `format`
* method, that attribute will never be persisted to the database, but it will
* also never be used when doing a `fetch()`, which may cause unexpected
* results. You should be very cautious with implementations of this method
* that may remove the primary key from the list of attributes.
*
* If you need to modify the database data before it is given to the model,
* override the {@link Model#parse parse} method instead. That method does the
* opposite operation of `format`.
*
* @param {Object} attributes The attributes to be converted.

@@ -673,2 +695,3 @@ * @returns {Object} Formatted attributes.

* initialize: function() {
* this.constructor.__super__.initialize.apply(this, arguments);
* this.on('saving', this.validateSave);

@@ -675,0 +698,0 @@ * },

@@ -834,4 +834,4 @@ 'use strict';

*
* @fires Model#"fetching:collection"
* @fires Model#"fetched:collection"
* @fires Model#fetching:collection
* @fires Model#fetched:collection
*

@@ -854,3 +854,3 @@ * @throws {Collection.EmptyError}

*
* @event Model#"fetching:collection"
* @event Model#fetching:collection
* @param {Model} collection The collection that has been fetched.

@@ -867,3 +867,3 @@ * @param {string[]} columns The columns being retrieved by the query.

*
* @event Model#"fetched:collection"
* @event Model#fetched:collection
* @param {Model} collection The collection that has been fetched.

@@ -1062,4 +1062,13 @@ * @param {Object} resp The Knex query response.

* @event Model#saving
* @param {Model} model The model firing the event.
* @param {Object} attrs Attributes that will be inserted or updated.
* @param {Model} model
* The model firing the event. Its attributes are already changed but
* not commited to the database yet.
* @param {Object} attrs
* Attributes that will be inserted or updated.
*
* **Note**: There's currently a bug that leads to attrs only
* containing attributes that were passed as argument to
* {@link Model#save save}. You can work around this by accessing
* `model.changed` which does contain all the attributes that will be
* inserted or updated.
* @param {Object} options Options object passed to {@link Model#save save}.

@@ -1078,3 +1087,10 @@ * @returns {Promise}

* @param {Model} model The model firing the event.
* @param {Object} attrs Attributes that will be inserted.
* @param {Object} attrs
* Attributes that will be inserted.
*
* **Note**: There's currently a bug that leads to attrs only
* containing attributes that were passed as argument to
* {@link Model#save save}. You can work around this by accessing
* `model.changed` which does contain all the attributes that will be
* inserted.
* @param {Object} options Options object passed to {@link Model#save save}.

@@ -1092,4 +1108,13 @@ * @returns {Promise}

* @event Model#updating
* @param {Model} model The model firing the event.
* @param {Object} attrs Attributes that will be updated.
* @param {Model} model
* The model firing the event. Its attributes are already changed but
* not commited to the database yet.
* @param {Object} attrs
* Attributes that will be updated.
*
* **Note**: There's currently a bug that leads to attrs only
* containing attributes that were passed as argument to
* {@link Model#save save}. You can work around this by accessing
* `model.changed` which does contain all the attributes that will be
* updated.
* @param {Object} options Options object passed to {@link Model#save save}.

@@ -1101,3 +1126,2 @@ * @returns {Promise}

}).then(function (resp) {
// After a successful database save, the id is updated if the model was created

@@ -1127,5 +1151,8 @@ if (method === 'insert' && this.id == null) {

* @event Model#saved
* @param {Model} model The model firing the event.
* @param {Object} resp The database response.
* @param {Object} options Options object passed to {@link Model#save save}.
* @param {Model} model The model firing the event.
* @param {(Array|Number)} response
* A list containing the id of the newly created model in case of an
* `insert` or a number representing the affected rows in the case of
* an `update` query.
* @param {Object} options Options object passed to {@link Model#save save}.
* @returns {Promise}

@@ -1141,3 +1168,3 @@ */

* @param {Model} model The model firing the event.
* @param {Object} attrs Model firing the event.
* @param {Array} newId A list containing the id of the newly created model.
* @param {Object} options Options object passed to {@link Model#save save}.

@@ -1153,5 +1180,5 @@ * @returns {Promise}

* @event Model#updated
* @param {Model} model The model firing the event.
* @param {Object} attrs Model firing the event.
* @param {Object} options Options object passed to {@link Model#save save}.
* @param {Model} model The model firing the event.
* @param {Number} affectedRows Number of rows affected by the update.
* @param {Object} options Options object passed to {@link Model#save save}.
* @returns {Promise}

@@ -1196,3 +1223,4 @@ */

*
* @returns {Promise<Model>} A promise resolving to the destroyed and thus "empty" model.
* @returns {Promise<Model>} A promise resolving to the destroyed and thus
* empty model, i.e. all attributes are `undefined`.
*/

@@ -1214,3 +1242,3 @@ destroy: _promise2.default.method(function (options) {

* @param {Model} model The model firing the event.
* @param {Object} options Options object passed to {@link Model#save save}.
* @param {Object} options Options object passed to {@link Model#destroy destroy}.
* @returns {Promise}

@@ -1221,4 +1249,4 @@ */

return sync.del();
}).then(function (resp) {
if (options.require && resp === 0) {
}).then(function (affectedRows) {
if (options.require && affectedRows === 0) {
throw new this.constructor.NoRowsDeletedError('No Rows Deleted');

@@ -1235,8 +1263,8 @@ }

* @event Model#destroyed
* @param {Model} model The model firing the event.
* @param {Object} attrs Model firing the event.
* @param {Object} options Options object passed to {@link Model#destroy destroy}.
* @param {Model} model The model firing the event.
* @param {Object} affectedRows Number of affected rows.
* @param {Object} options Options object passed to {@link Model#destroy destroy}.
* @returns {Promise}
*/
return this.triggerThen('destroyed', this, resp, options);
return this.triggerThen('destroyed', this, affectedRows, options);
}).then(this._reset);

@@ -1243,0 +1271,0 @@ }),

@@ -415,5 +415,10 @@ 'use strict';

}
if (groupedKey) {
if (!_lodash2.default.isNil(groupedKey)) {
var relation = model.relations[relationName] = _this.relatedInstance(grouped[groupedKey]);
relation.relatedData = _this;
if (_this.type === 'belongsToMany') {
// If type is of "belongsToMany" then the relatedData need to be recreated through the parent model
relation.relatedData = model[relationName]().relatedData;
} else {
relation.relatedData = _this;
}
if (_this.isJoined()) _lodash2.default.extend(relation, pivotHelpers);

@@ -427,2 +432,3 @@ }

model.attributes = model.parse(model.attributes);
model._reset();
});

@@ -549,3 +555,3 @@

* @returns {Promise<Collection>}
* A promise resolving to the updated Collection.
* A promise resolving to the updated Collection where this method was called.
*/

@@ -567,5 +573,5 @@ attach: function attach(ids, options) {

* Detach one or more related objects from their pivot tables. If a model or
* id is passed, it attempts to remove the pivot table based on that foreign
* key. If no parameters are specified, we assume we will detach all related
* associations.
* id is passed, it attempts to remove from the pivot table based on that
* foreign key. If no parameters are specified, we assume we will detach all
* related associations.
*

@@ -584,3 +590,3 @@ * This method (along with {@link Collection#attach} and {@link

* @returns {Promise<undefined>}
* A promise resolving to `undefined`.
* A promise resolving to the updated Collection where this method was called.
*/

@@ -587,0 +593,0 @@ detach: function detach(ids, options) {

{
"name": "bookshelf",
"version": "0.12.0",
"version": "0.12.1",
"description": "A lightweight ORM for PostgreSQL, MySQL, and SQLite3",

@@ -31,5 +31,5 @@ "main": "bookshelf.js",

"dependencies": {
"babel-runtime": "^6.6.1",
"babel-runtime": "^6.26.0",
"bluebird": "^3.4.3",
"chalk": "^1.0.0",
"chalk": "^2.3.0",
"create-error": "~0.3.1",

@@ -41,11 +41,10 @@ "inflection": "^1.5.1",

"devDependencies": {
"babel-cli": "^6.0.15",
"babel-eslint": "^8.0.1",
"babel-plugin-syntax-object-rest-spread": "^6.0.14",
"babel-plugin-transform-object-rest-spread": "^6.0.14",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015": "^6.0.14",
"bookshelf-jsdoc-theme": "^0.1.2",
"babel-cli": "^6.26.0",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"bookshelf-jsdoc-theme": "^0.2.0",
"chai": "^3.5.0",
"eslint": "2.13.1",
"eslint": "4.15.0",
"istanbul": "^0.4.5",

@@ -59,6 +58,6 @@ "jsdoc": "^3.4.0",

"semver": "^5.0.3",
"sinon": "^1.11.1",
"sinon": "^4.1.3",
"sinon-chai": "^2.6.0",
"sqlite3": "^3.0.5",
"uuid": "~3.0.0"
"uuid": "^3.1.0"
},

@@ -65,0 +64,0 @@ "peerDependencies": {

# [bookshelf.js](http://bookshelfjs.org)
[![NPM Version](https://img.shields.io/npm/v/bookshelf.svg?style=flat)](https://www.npmjs.com/package/bookshelf)
[![Build Status](https://travis-ci.org/bookshelf/bookshelf.svg?branch=master)](https://travis-ci.org/bookshelf/bookshelf)

@@ -13,4 +14,6 @@ [![Dependency Status](https://david-dm.org/bookshelf/bookshelf/status.svg)](https://david-dm.org/bookshelf/bookshelf)

## [Read the discussion about the future of bookshelf.js](https://github.com/bookshelf/bookshelf/issues/1600)
## Notice
This project is currently undergoing some changes. You may want to [read the discussion about the future of bookshelf.js](https://github.com/bookshelf/bookshelf/issues/1600) on GitHub.
## Introduction

@@ -128,2 +131,4 @@

* [bookshelf-secure-password](https://github.com/venables/bookshelf-secure-password) - A plugin for easily securing passwords using bcrypt.
* [bookshelf-default-select](https://github.com/DJAndries/bookshelf-default-select) - Enables default column selection for models. Inspired by [Visibility](https://github.com/tgriesser/bookshelf/wiki/Plugin:-Visibility), but operates on the database level.
* [bookshelf-ez-fetch](https://github.com/DJAndries/bookshelf-ez-fetch) - Convenient fetching methods which allow for compact filtering, relation selection and error handling.

@@ -130,0 +135,0 @@ ## Support

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc