1
1
! function ( e ) { if ( "object" == typeof exports && "undefined" != typeof module ) module . exports = e ( ) ; else if ( "function" == typeof define && define . amd ) define ( [ ] , e ) ; else { var f ; "undefined" != typeof window ?f = window :"undefined" != typeof global ?f = global :"undefined" != typeof self && ( f = self ) , f . Bookshelf = e ( ) } } ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; throw new Error ( "Cannot find module '" + o + "'" ) } var f = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( f . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , f , f . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( _dereq_ , module , exports ) {
2
- // Bookshelf.js 0.7.5
2
+ // Bookshelf.js 0.7.6
3
3
// ---------------
4
4
5
5
// (c) 2013 Tim Griesser
@@ -16,7 +16,7 @@ var Bookshelf = function() {
16
16
// `Model` and `Collection` constructors for use in the current instance.
17
17
Bookshelf . initialize = function ( knex ) {
18
18
var bookshelf = {
19
- VERSION : '0.7.5 '
19
+ VERSION : '0.7.6 '
20
20
} ;
21
21
22
22
var _ = _dereq_ ( 'lodash' ) ;
@@ -523,14 +523,17 @@ _.extend(ModelBase.prototype, _.omit(Backbone.Model.prototype, modelOmitted), Ev
523
523
// Returns an object containing a shallow copy of the model attributes,
524
524
// along with the `toJSON` value of any relations,
525
525
// unless `{shallow: true}` is passed in the `options`.
526
+ // Also includes _pivot_ keys for relations unless `{omitPivot: true}`
527
+ // is passed in `options`.
526
528
toJSON : function ( options ) {
527
529
var attrs = _ . extend ( { } , this . attributes ) ;
528
530
if ( options && options . shallow ) return attrs ;
529
531
var relations = this . relations ;
530
532
for ( var key in relations ) {
531
533
var relation = relations [ key ] ;
532
- attrs [ key ] = relation . toJSON ? relation . toJSON ( ) : relation ;
534
+ attrs [ key ] = relation . toJSON ? relation . toJSON ( options ) : relation ;
533
535
}
536
+ if ( options && options . omitPivot ) return attrs ;
534
537
if ( this . pivot ) {
535
538
var pivot = this . pivot . attributes ;
536
539
for ( key in pivot ) {
@@ -616,6 +619,7 @@ _.extend(ModelBase.prototype, _.omit(Backbone.Model.prototype, modelOmitted), Ev
616
619
ModelBase . extend = _dereq_ ( 'simple-extend' ) ;
617
620
618
621
module . exports = ModelBase ;
622
+
619
623
} , { "./events" :4 , "./promise" :6 , "backbone" :"5kFNoY" , "lodash" :"K2RcUv" , "simple-extend" :"vZYVcT" } ] , 6 :[ function ( _dereq_ , module , exports ) {
620
624
var Promise = _dereq_ ( 'bluebird' ) ;
621
625
0 commit comments