UNPKG

22.8 kBMarkdownView Raw
1## Change Log
2
3**0.10.1** - <small>_Jun 29, 2016_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.10.0...0.10.1)
4
5* Allows using knex 0.12 as a peerDependency
6* knex instance used by bookshelf may be swapped out
7
8## Change Log
9
10**0.10.0**<small>_Jun 29, 2016_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.9.5...0.10.0)
11
12**Breaking Changes:**
13
14* Removal/renaming of certain lodash functions from Model and Collection that were removed in lodash 4.
15 * Collection Methods
16 * removed `CollectionBase#collect` => use `CollectionBase#map` instead
17 * removed `CollectionBase#foldl` => use `CollectionBase#reduce` instead
18 * removed `CollectionBase#inject` => use `CollectionBase#reduce` instead
19 * removed `CollectionBase#foldr` => use `CollectionBase#reduceRight` instead
20 * removed `CollectionBase#detect` => use `CollectionBase#find` instead
21 * removed `CollectionBase#select` => use `CollectionBase#filter` instead
22 * removed `CollectionBase#all` => use `CollectionBase#every` instead
23 * removed `CollectionBase#any` => use `CollectionBase#some` instead
24 * removed `CollectionBase#include` => use `CollectionBase#includes` instead
25 * removed `CollectionBase#contains` => use `CollectionBase#includes` instead
26 * removed `CollectionBase#rest` => use `CollectionBase#tail instead`
27 * renamed `CollectionBase#invoke` => `CollectionBase#invokeMap`
28 * split `CollectionBase#max` into `CollectionBase#maxBy` - see the [lodash docs](https://lodash.com/docs/#max) for more explanation
29 * split `CollectionBase#min` into `CollectionBase#minBy` - see the [lodash docs](https://lodash.com/docs/#min) for more explanation
30 * Model Methods
31 * renamed `ModelBase#pairs` => `ModelBase#toPairs`
32
33**Other Changes:**
34
35* Update to Lodash 4. #1287
36* Registry plugin: Better support for custom relations. #1294
37
38**0.9.5**<small>_May 15, 2016_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.9.4...0.9.5)
39
40* Add pagination plugin. #1183
41* Fire {@link Model#event:fetched} on eagerly loaded relations. #1206
42* Correct cloning of {@link Model#belongsToMany} decorated relations. #1222
43* Update Knex to 0.11.x. #1227
44* Update minimum lodash version. #1230
45
46**0.9.4**<small>_April 3, 2016_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.9.3...0.9.4)
47
48* Include `babel-runtime` as a dependency. #1188
49
50**0.9.3**<small>_April 3, 2016_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.9.2...0.9.3)
51
52* Bugfix: Restore support for `camelCase` and `color:separated` event names. #1184
53
54**0.9.2**<small>_February 17, 2016_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.9.1...0.9.2)
55
56* Permit up to Knex 0.11.0 via `peerDependencies`.
57* `Model.forge` works for ES6 classes. #924
58* Fix `Collection#count` for `hasMany` relations. #1115
59
60**0.9.1**<small>_November 4, 2015_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.9.0...0.9.1)
61
62* {@link Events#off} can now deregister multiple methods at once. #983
63* Permit Knex 0.10.0 via `peerDependencies`. #998
64
65**0.9.0**<small>_November 1, 2015_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.8.2...0.9.0)
66
67* Repo no longer includes built source or generated documentation. Release script updated to include these only in the tagged release commit. #950.
68* {@link Model#previous} returned `undefined` instead of `null` for non-existant attributes.
69* Update tests and documentation to confirm that `null` (rather than `undefined`) is returned from {@link Model#fetch} and {@link Collection#fetchOne}.
70* Fix error in virtual plugin - #936
71* Correct error updating parsed/formatted {@link Model#idAttribute} after successful `insert` operation. #955
72* Many documentation fixes.
73
74**0.8.2**<small>_August 20, 2015_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.8.1...0.8.2)
75
76* ES6/7: Move code base to `/src` — code is now compiled into `/lib` via [Babel](https://babeljs.io/).
77* Add `collection.count`, `model.count` and `Model.count`.
78* Add `model.refresh`. #796
79* Prevent `fetch` and `refresh` from trying to add JSON attributes to a `where` clause. #550 #778
80* Virtuals plugin now supports `{patch: true}` argument to `model.save`. #542
81* Restored `model.clone` and `collection.clone`, which were not previously working. #744
82* Allow `bookshelf.Collection` to be modified and extended by plugins (so that relations and `fetchAll` operations will return the extended instance). #681 #688
83* Fix `model.timestamps` behaviour which deviated from documentation. Also ensure that `createdAt` is set when `{method: "insert"}` is passed explicitly. #787
84* Calling `create` on a `through` relationship no longer tries to make a pivot object. Previously this would attempt to create an object with invalid foreign keys. #768
85* Parse foreign keys set during `create` in a relation. #770
86
87**0.8.1**<small>_May 12, 2015_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.8.0...0.8.1)
88
89* Fix for regression in `initialize` not being called in Collection constructor, #737.
90* Fix for regression, removing `omitPivot` in 0.8 #721
91* Added `serialize`, a method which contains toJSON logic for easier customization.
92
93**0.8.0**<small>_May 1, 2015_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.9...0.8.0)
94
95* Dropped Backbone dependency
96* More specific errors throughout, #522
97* Support {require: true} for model.destroy #617
98* Add lifecycle events on pivot models for belongsToMany, .through #578
99* Allows for select/column calls in the query builder closure, #633.
100* Added per-constructor error classes #694 (note: this will not work in CoffeeScript).
101
102**Breaking Changes:**
103
104* Removed the `__super__` internal property on the constructor, this shouldn't have been something you were relying on anyway.
105
106**0.7.9**<small>_Oct 28, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.8...0.7.9)
107
108* Fix for regression in columns / eager fetch query constraints, (#510).
109
110**0.7.8**<small>_Oct 28, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.7...0.7.8)
111
112* Timestamp `created_at` is now saved with any insert.
113* Fix for regression created by #429.
114* New events, `attaching`, `attached`, `detaching`, `detached` #452.
115* Ability to specify custom column names in morphTo, #454
116* Fix for stack overflow with model list as arguments, #482
117* Modified location of eager fetch query constraints internally.
118
119**0.7.7**<small>_July 23, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.6...0.7.7)
120
121* Fix for formatting on polymorphic keys, (#429).
122* Added a resolve method for specifying a custom resolver function for the registry plugin.
123
124**0.7.6**<small>_June 29, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.5...0.7.6)
125 Add `omitPivot` flag on toJSON options for omitting the `_pivot_` keys in `through` and `belongsToMany` relations (#404).
126
127**0.7.5**<small>_June 23, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.4...0.7.5)
128 Fix missing NotFoundError & EmptyError on Model & Collection, respectively (#389, 399).
129
130**0.7.4**<small>_June 18, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.3...0.7.4)
131 Added `bookshelf.model(name, protoProps, [staticProps])` syntax for registry plugin.
132
133**0.7.3**<small>_June 17, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.2...0.7.3)
134 Fix for collection dropping models early in set, #376.
135
136**0.7.2**<small>_June 12, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.1...0.7.2)
137 Pass a cloned copy of the model's attributes to `format` rather than the original, related to #315.
138
139**0.7.1**<small>_June 10, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.7.0...0.7.1)
140 Ensure the knex version >= 0.6.10, where a major regression affecting column names was fixed.
141
142**0.7.0**<small>_June 9, 2014_</small>
143
144* Added {@link Model#fetchAll}, for fetching a collection of models from a model.
145* Added {@link Model#where}, as a shortcut for the most commonly used {@linkplain Model#query query method}.
146* Initializing via a plain options object is deprecated, you must now pass in an initialized knex instance.
147* Adding typed errors (#221).
148* Upgrade to support knex 0.6.x
149
150**0.6.12**<small>_June 5, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.11...0.6.12)
151 Fix for eager loaded belongsTo relation bug with custom parse/format (#377).
152
153**0.6.11**<small>_June 4, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.10...0.6.11)
154 Temporarily add knex to `peerDependencies` until 0.7 is released to support knex 0.6 and there exists a better internal method of doing a semver check. Fix for belongsTo relation bug (#353).
155
156**0.6.10**<small>_April 3, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.9...0.6.10)
157
158* Bumping dependencies, including upgrading to Bluebird 1.2, trigger-then 0.3, fixing an erroneous "unhandledRejection" (#310).
159* `fetchOne` properly resets the query on the collection, (#300).
160
161**0.6.9**<small>_April 3, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.8...0.6.9)
162 Only prefix model fields with the "tableName" after format has been called, (#308).
163
164**0.6.8**<small>_March 6, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.7...0.6.8)
165
166* Virtuals plugin may now accept a hash of attributes to set.
167* Properly fix issue addressed in 0.6.7.
168
169**0.6.7**<small>_March 2, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.6...0.6.7)
170 Bugfix for edge case for eager loaded relations and `relatedData` settings.
171
172**0.6.6**<small>_March 1, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.5...0.6.6)
173 Bugfix for registry plugin, resolving correct models for "through" relations. (#260)
174
175**0.6.5**<small>_February 28, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.4...0.6.5)
176
177* Added {@link Collection#reduceThen} as a passthrough to Bluebird's "reduce" method with models.
178* Options are now passed to "plugin" method. (#254)
179* Bugfix for registry plugin. (#259)
180
181**0.6.4**<small>_February 11, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.3...0.6.4)
182 Adds static method {@link Model.collection Model.collection()} as a shortcut for creating a collection with the current model.
183
184**0.6.3**<small>_February 9, 2014_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.2...0.6.3)
185
186* Added an` Relation#updatePivot` method for updating tables on a "belongsToMany" relation. (#134, #230)
187* Allow mutating the options for passing constraints to eager loaded relations. (#151)
188* All keys of an object passed into sync are properly prefixed before sync. (#177)
189* Clearer error messages for debugging. (#204, #197)
190* Fixed error message for updates that don't affect rows. (#228)
191* Group by the correct key on "belongsTo.through" relations. (#214)
192* Ability to only use `created_at` or `updated_at` as timestamp properties. (#158)
193* Numerous documentation corrections, clarifications, enhancements.
194* Bumped Bluebird dependency to ~1.0.0.
195
196**Plugins:**
197
198* Added the `registry` plugin for registering models as strings, helping with the circular dependency problem
199* Added the `virtuals` plugin for getting/setting virtual (computed) properties on the model.
200* Added the `visibility` plugin for specifying a whitelist/blacklist of keys when a model is serialized with toJSON.
201
202**0.6.2**<small>_December 18, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.1...0.6.2)
203
204* Debug may now be passed as an option in any sync method, to log queries, including relations.
205* Save now triggers an error in updates with no affected rows. (#119)
206* The `model.id` attribute is only set on insert if it's empty. (#130)
207* Ensure eager loaded relations can use attach/detach. (#120)
208
209**0.6.1**<small>_November 26, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.6.0...0.6.1)
210 Fixes bug with promise code and saving event firing, where promises are not properly resolved with ".all" during saving events.
211
212**0.6.0**<small>_November 25, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.8...0.6.0)
213
214* Updating dependency to knex.js 0.5.x
215* Switched from when.js to [bluebird](https://github.com/petkaantonov/bluebird) for promise implementation, with shim for backward compatibility.
216* Switched from underscore to lodash, for semver reliability.
217
218**0.5.8**<small>_November 24, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.7...0.5.8)
219
220* Parse models after all relations have been eager loaded, for appropriate column name matching (thanks [@benesch](https://github.com/benesch)) (#97)
221* Specify table for `withRelated` fetches to prevent column naming conflicts (#96).
222* Fix for polymorphic relation loading (#95).
223* Other documentation tweaks and other internal code cleanup.
224
225**0.5.7**<small>_October 11, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.6...0.5.7)
226 The "fetching" event is now fired on eager loaded relation fetches.
227
228**0.5.6**<small>_October 10, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.5...0.5.6)
229 The `options.query` now contains the appropriate `knex` instance during the "fetching" event handler.
230
231**0.5.5**<small>_October 1, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.4...0.5.5)
232 An eager loaded [morphTo](#Model-morphTo) relation may now have child relations nested beneath it that are properly eager loaded, depending on the parent.
233
234**0.5.4**<small>_October 1, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.3...0.5.4)
235
236* Fix issue where the `relatedData` context was not appropriately maintained for subsequent {@link Collection#create} calls after an eager load (#77).
237* Documentation improvements, encouraging the use of {@link Model#related} rather than calling a relation method directly, to keep association with the parent model's {@link Model#relations relations} hash.
238
239**0.5.3**<small>_September 26, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.2...0.5.3)
240 The `columns` explicitly specified in a fetch are no-longer passed along when eager loading relations, fixes (#70).
241
242**0.5.2**<small>_September 22, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.1...0.5.2)
243 Fixed incorrect eager loading in `belongsTo` relations (#65).
244
245**0.5.1**<small>_September 21, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.5.0...0.5.1)
246 Fixed incorrect eager loading in `hasOne` relations (#63).
247
248**0.5.0**<small>_September 20, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.3.1...0.5.0)
249 **Major Breaking Changes:**
250
251* Global state is no longer stored in the library, an instance is returned from `Bookshelf.initialize`, so you will need to call this once and then reference this `Bookshelf` client elsewhere in your application.
252* Lowercasing of `bookshelf.initialize`, `bookshelf.knex`, `bookshelf.transaction`.
253* During the lifecycle events, such as "fetching", "saving", or "destroying", the model no-longer contains the active query builder instance at the time it is saved. If you need to modify the query builder chain inside of an event handler, you may now use `options.query` inside the event handlers.
254
255**Other Changes:**
256
257* Added `tableName` for all queries, so joins use the correct id (#61).
258* The `attach` & `detach` now remove models from the associated collection, as appropriate (#59).
259* A `withPivot` no longer accepts an object to specify the keys for the returned pivot items, if you wish to specify how these pivot objects are defined on the object, a custom [toJSON](#Model-toJSON) is your best bet.
260* Added {@link Collection#invokeThen} and {@link Collection#mapThen} as convenience helpers for `Promise.all(collection.invoke(method, args*))` and `Promise.all(collection.map(method, iterator, [context]))`, respectively.
261* Added a `Bookshelf.plugin` method, for a standard way to extend Bookshelf instances.
262* A re-written modular architecture, to move the library toward becoming a database agnostic "data mapper" foundation, with the ablitiy to form relations between different data stores and types, not just SQL (although SQL is the primary focus for now). Also, support for AMD, for eventual use outside of Node.js runtime (with webSQL and likewise).
263
264**0.3.1**<small>_August 29, 2013_</small> — [Diff](https://github.com/tgriesser/bookshelf/compare/0.3.0...0.3.1) — [Docs](http://htmlpreview.github.com/?https://raw.github.com/tgriesser/bookshelf/0.3.0/index.html)
265 Fixed regression in `belongsToMany` custom column name order.
266
267**0.3.0**<small>_August 28, 2013_</small>
268 Support for a {@link Model#through} clause on various model relations. Creating a model from a related collection maintains the appropriate relation data (#35). Support for a `{patch: true}` flag on save, to only update specific saved attributes. Added a `fetchOne` method, for pulling out a single model from a collection, mostly useful for related collection instances. Updated to Knex "0.2.x" syntax for insert / returning, Ability to specify a `morphValue` on {@link Model#morphOne} or {@link Model#morphMany} relations. Internal refactor of relations for more consistent behavior.
269
270**0.2.8**<small>_August 26, 2013_</small>
271 Some minor fixes to make the `Sync` methods more consistent in their behavior when called directly, (#53).
272
273**0.2.7**<small>_August 21, 2013_</small>
274 Timestamp for `created_at` is not set during an "update" query, and the update where clause does not include the `idAttribute` if it isn't present (#51).
275
276**0.2.6**<small>_August 21, 2013_</small>
277 Fixes bug with query function feature added in `0.2.5`, mentioned in (#51).
278
279**0.2.5**<small>_August 19, 2013_</small>
280 The {@link Model#query} method may now accept a function, for even more dynamic query building (#45). Fix for relations not allowing "0" as a valid foreign key value (#49).
281
282**0.2.4**<small>_July 30, 2013_</small>
283 More consistent query resetting, fixing query issues on post-query event handlers. The `toJSON` is only called on a related model if the method exists, allowing for objects or arrays to be manually specified on the `relations` hash and serialized properly on the parent's `toJSON`.
284
285**0.2.3**<small>_July 7, 2013_</small>
286 Fixing bug where `triggerThen` wasn't actually being used for several of the events as noted in 0.2.1 release.
287
288**0.2.2**<small>_July 2, 2013_</small>
289 The Model's `related` method is now a no-op if the model doesn't have the related method. Any `withPivot` columns on many-to-many relations are now prefixed with `_pivot` rather than `pivot` unless named otherwise, for consistency. The `_reset` is not called until after all triggered events so that `hasChanged` can be used on the current model state in the "created", "updated", "saved", and "destroyed" events. Eager queries may be specified as an object with a function, to constrain the eager queries:
290
291 user.fetch({withRelated: ['accounts', {
292 'accounts.settings': function(qb) { qb.where('status', 'enabled'); }
293 }, 'other_data']}).then(...
294
295**0.2.1**<small>_June 26, 2013_</small>
296 Using `triggerThen` instead of `trigger` for "created", "updated", "saved", "destroyed", and "fetched" events - if any async operations are needed _after_ the model is created but before resolving the original promise.
297
298**0.2.0**<small>_June 24, 2013_</small>
299 Resolve Model's `fetch` promise with `null` rather than undefined. An object of `query`. constraints (e.g. `{where: {...}, orWhere: {...}}`may be passed to the query method (#30). Fix for empty eager relation responses not providing an empty model or collection instance on the `model.relations` object.
300
301**0.1.9**<small>_June 19, 2013_</small>
302 Resolve Model's `fetch` promise with `undefined` if no model was returned. An array of "created at" and "updated at" values may be used for `hasTimestamps`. Format is called on the `Model#fetch` method. Added an `exec` plugin to provide a node callback style interface for any of the promise methods.
303
304**0.1.8**<small>_June 18, 2013_</small>
305 Added support for polymorphic associations, with `morphOne`, `morphMany`, and `morphTo` model methods.
306
307**0.1.7**<small>_June 15, 2013_</small>
308 Bugfix where `detach` may be used with no parameters to detach all related items (#19).
309
310**0.1.6**<small>_June 15, 2013_</small>
311 Fixing bug allowing custom `idAttribute` values to be used in eager loaded many-to-many relations (#18).
312
313**0.1.5**<small>_June 11, 2013_</small>
314 Ensuring each of the `_previousAttribute` and `changed` values are properly reset on related models after sync actions.
315
316**0.1.4**<small>_June 10, 2013_</small>
317 Fixing issue with `idAttribute` not being assigned after database inserts. Removing various aliases {@link Events} methods for clarity.
318
319**0.1.3**<small>_June 10, 2013_</small>
320 Added {@link Model#hasChanged}, {@link Model#previous}, and {@link Model#previousAttributes} methods, for getting the previous value of the model since the last sync. Using `Object.create(null)` for various internal model objects dealing with user values. Calling {@link Model#related} on a model will now create an empty related object if one is not present on the `relations` object. Removed the `{patch: true}` option on save, instead only applying defaults if the object `isNew`, or if `{defaults: true}` is passed. Fix for `model.clone`'s relation responses.
321
322**0.1.2**<small>_May 17, 2013_</small>
323 Added `triggerThen` and `emitThen` for promise based events, used internally in the "creating", "updating", "saving", and "destroying" events. Docs updates, fixing `{patch: true}` on `update` to have intended functionality. A model's `toJSON` is now correctly called on any related properties.
324
325**0.1.1**<small>_May 16, 2013_</small>
326 Fixed bug with eager loaded `belongsTo` relations (#14).
327
328**0.1.0**<small>_May 13, 2013_</small>
329 Initial Bookshelf release.