Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.13.0 to 0.13.2

8

CHANGELOG.md
## Change Log
**0.13.2** <small>_Mar 23, 2018_</small> - [Diff](https://github.com/bookshelf/bookshelf/compare/0.13.0...0.13.2)
#### Bug fixes
- Fix timestamps set with Invalid Date in some cases: [#1796](https://github.com/bookshelf/bookshelf/pull/1796)
#### Documentation
- Fix incorrect data types and undocumented Model#defaults property: [#1797](https://github.com/bookshelf/bookshelf/pull/1797)
**0.13.0** <small>_Mar 18, 2018_</small> - [Diff](https://github.com/bookshelf/bookshelf/compare/0.12.1...0.13.0)

@@ -4,0 +12,0 @@

6

lib/base/collection.js

@@ -164,5 +164,5 @@ 'use strict';

* @param {Object=} options
* @param {bool} [options.shallow=false] Exclude relations.
* @param {bool} [options.omitPivot=false] Exclude pivot values.
* @param {bool} [options.omitNew=false] Exclude models that return true for isNew.
* @param {Boolean} [options.shallow=false] Exclude relations.
* @param {Boolean} [options.omitPivot=false] Exclude pivot values.
* @param {Boolean} [options.omitNew=false] Exclude models that return true for isNew.
* @returns {Object} Serialized model as a plain object.

@@ -169,0 +169,0 @@ */

@@ -160,3 +160,27 @@ 'use strict';

/**
* @member {boolean|Array}
* @member {Object|Null}
* @default null
* @description
*
* This can be used to define any default values for attributes that are not
* present when creating or updating a model in a {@link Model#save save} call.
* The default behavior is to *not* use these default values on updates unless
* the `defaults: true` option is passed to the {@link Model#save save} call.
* For inserts the default values will always be used if present.
*
* @example
*
* var MyModel = bookshelf.Model.extend({
* defaults: {property1: 'foo', property2: 'bar'},
* tableName: 'my_table'
* })
*
* MyModel.forge({property1: 'blah'}).save().then(function(model) {
* // {property1: 'blah', property2: 'bar'}
* })
*/
ModelBase.prototype.defaults = null;
/**
* @member {Boolean|Array}
* @default false

@@ -167,3 +191,3 @@ * @description

* `updated_at` for a given method. The 'update' method will only update
* `updated_at`. To override the default column names, assign an array
* `updated_at`. To override the default column names, assign an array
* to {@link Model#hasTimestamps hasTimestamps}. The first element will

@@ -201,3 +225,3 @@ * be the created column name and the second will be the updated

this.getTimestampKeys().forEach(function (key) {
_this.set(key, new Date(_this.get(key)));
if (_this.get(key)) _this.set(key, new Date(_this.get(key)));
});

@@ -345,4 +369,4 @@

* @param {Object=} options
* @param {bool} [options.shallow=false] Exclude relations.
* @param {bool} [options.omitPivot=false] Exclude pivot values.
* @param {Boolean} [options.shallow=false] Exclude relations.
* @param {Boolean} [options.omitPivot=false] Exclude pivot values.
* @returns {Object} Serialized model as a plain object.

@@ -424,3 +448,3 @@ */

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

@@ -669,3 +693,3 @@ ModelBase.prototype.has = function (attr) {

* @param {string=} attribute
* @returns {bool}
* @returns {Boolean}
* `true` if any attribute has changed. Or, if `attribute` was specified, true

@@ -672,0 +696,0 @@ * if it has changed.

@@ -82,7 +82,7 @@ 'use strict';

* @param {string=} options.tableName Initial value for {@linkcode Model#tableName tableName}.
* @param {boolean=} [options.hasTimestamps=false]
* @param {Boolean=} [options.hasTimestamps=false]
*
* Initial value for {@linkcode Model#hasTimestamps hasTimestamps}.
*
* @param {boolean} [options.parse=false]
* @param {Boolean} [options.parse=false]
*

@@ -89,0 +89,0 @@ * Convert attributes by {@linkcode Model#parse parse} before being

@@ -63,3 +63,3 @@ 'use strict';

* @param {Object=} options
* @param {bool} [options.comparator=false]
* @param {Boolean} [options.comparator=false]
* {@link Collection#comparator Comparator} for collection, or `false` to disable sorting.

@@ -134,3 +134,3 @@ */

* @param {Object=} options
* @param {bool} [options.require=false] Trigger a {@link Collection.EmptyError} if no records are found.
* @param {Boolean} [options.require=false] Trigger a {@link Collection.EmptyError} if no records are found.
* @param {string|string[]} [options.withRelated=[]] A relation, or list of relations, to be eager loaded as part of the `fetch` operation.

@@ -237,3 +237,3 @@ * @returns {Promise<Collection>}

* @param {Object=} options
* @param {boolean} [options.require=false]
* @param {Boolean} [options.require=false]
* If `true`, will reject the returned response with a {@link

@@ -240,0 +240,0 @@ * Model.NotFoundError NotFoundError} if no result is found.

@@ -90,7 +90,7 @@ 'use strict';

* @param {string=} options.tableName Initial value for {@link Model#tableName tableName}.
* @param {boolean=} [options.hasTimestamps=false]
* @param {Boolean=} [options.hasTimestamps=false]
*
* Initial value for {@link Model#hasTimestamps hasTimestamps}.
*
* @param {boolean} [options.parse=false]
* @param {Boolean} [options.parse=false]
*

@@ -699,3 +699,3 @@ * Convert attributes by {@link Model#parse parse} before being {@link

* @param {Object=} options - Hash of options.
* @param {boolean=} [options.require=false]
* @param {Boolean=} [options.require=false]
* Reject the returned response with a {@link Model.NotFoundError

@@ -826,3 +826,3 @@ * NotFoundError} if results are empty.

* @param {Object=} options - Hash of options.
* @param {boolean=} [options.require=false]
* @param {Boolean=} [options.require=false]
*

@@ -919,3 +919,3 @@ * Rejects the returned promise with an `Collection.EmptyError` if no records are returned.

*
* `save` is used to perform either an insert or update query using the
* This method is used to perform either an insert or update query using the
* model's set {@link Model#attributes attributes}.

@@ -925,13 +925,22 @@ *

* will be set and an `insert` query will be performed. Otherwise it will
* `update` the record with a corresponding ID. This behaviour can be overriden
* with the `method` option.
* `update` the record with a corresponding ID. It is also possible to
* set default attributes on an `update` by passing the `{defaults: true}`
* option in the second argument to the `save` call. This will also use the
* same {@link Model#defaults defaults} as the `insert` operation.
*
* new Post({name: 'New Article'}).save().then(function(model) {
* // ...
* });
* The type of operation to perform (either `insert` or `update`) can be
* overriden with the `method` option:
*
* // This forces an insert with the specified id instead of the expected
* // update
* new Post({name: 'New Article', id: 34})
* .save(null, {method: 'insert'})
* .then(function(model) {
* // ...
* });
*
* If you only wish to update with the params passed to the save, you may pass
* a {patch: true} flag to the database:
* a `{patch: true}` option in the second argument to `save`:
*
* // update authors set "bio" = 'Short user bio' where "id" = 1
* // UPDATE authors SET "bio" = 'Short user bio' WHERE "id" = 1
* new Author({id: 1, first_name: 'User'})

@@ -955,9 +964,15 @@ * .save({bio: 'Short user bio'}, {patch: true})

* // Save with no arguments
* Model.forge({id: 5, firstName: "John", lastName: "Smith"}).save().then(function() { //...
* Model.forge({id: 5, firstName: 'John', lastName: 'Smith'}).save().then(function() {
* //...
* });
*
* // Or add attributes during save
* Model.forge({id: 5}).save({firstName: "John", lastName: "Smith"}).then(function() { //...
* Model.forge({id: 5}).save({firstName: 'John', lastName: 'Smith'}).then(function() {
* //...
* });
*
* // Or, if you prefer, for a single attribute
* Model.forge({id: 5}).save('name', 'John Smith').then(function() { //...
* Model.forge({id: 5}).save('name', 'John Smith').then(function() {
* //...
* });
*

@@ -972,7 +987,8 @@ * @param {string=} key Attribute name.

* Explicitly select a save method, either `"update"` or `"insert"`.
* @param {string} [options.defaults=false]
* Assign {@link Model#defaults defaults} in an `update` operation.
* @param {bool} [options.patch=false]
* @param {Boolean} [options.defaults=false]
* Whether to assign or not {@link Model#defaults default} attribute values
* on a model when performing an update or create operation.
* @param {Boolean} [options.patch=false]
* Only save attributes supplied in arguments to `save`.
* @param {bool} [options.require=true]
* @param {Boolean} [options.require=true]
* Throw a {@link Model.NoRowsUpdatedError} if no records are affected by save.

@@ -1200,3 +1216,3 @@ *

* @param {Transaction=} options.transacting Optionally run the query in a transaction.
* @param {bool} [options.require=true]
* @param {Boolean} [options.require=true]
* Throw a {@link Model.NoRowsDeletedError} if no records are affected by destroy. This is

@@ -1203,0 +1219,0 @@ * the default behavior as of version 0.13.0.

@@ -618,3 +618,3 @@ 'use strict';

* Model#query}.
* @param {bool} [options.require=false]
* @param {Boolean} [options.require=false]
* Causes promise to be rejected with an Error if no rows were updated.

@@ -621,0 +621,0 @@ * @param {Transaction} [options.transacting]

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

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

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