File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -795,13 +795,17 @@ module.exports = function(AV) {
795795 * completes.
796796 */
797797 fetch : function ( ) {
798- var options = null ;
798+ var options = { } ;
799799 var fetchOptions = { } ;
800800 if ( arguments . length === 1 ) {
801801 options = arguments [ 0 ] ;
802802 } else if ( arguments . length === 2 ) {
803803 fetchOptions = arguments [ 0 ] ;
804- options = arguments [ 1 ] ;
804+ options = arguments [ 1 ] || { } ;
805+ }
806+
807+ if ( fetchOptions && fetchOptions . include && fetchOptions . include . length > 0 ) {
808+ fetchOptions . include = fetchOptions . include . join ( ',' ) ;
805809 }
806810
807811 var self = this ;
Original file line number Diff line number Diff line change @@ -350,6 +350,19 @@ describe('Objects', function(){
350350 } ) ;
351351 } ) ;
352352
353+ it ( 'should fetch include authors successfully' , function ( ) {
354+ var myPost = new Post ( ) ;
355+ myPost . set ( 'author1' , new Person ( { name : '1' } ) ) ;
356+ myPost . set ( 'author2' , new Person ( { name : '2' } ) ) ;
357+ return myPost . save ( ) . then ( function ( ) {
358+ myPost = AV . Object . createWithoutData ( 'Post' , myPost . id ) ;
359+ return myPost . fetch ( { include : [ 'author1' , 'author2' ] } , { } ) . then ( function ( ) {
360+ expect ( myPost . get ( 'author1' ) . get ( 'name' ) ) . to . be ( '1' ) ;
361+ expect ( myPost . get ( 'author2' ) . get ( 'name' ) ) . to . be ( '2' ) ;
362+ } ) ;
363+ } ) ;
364+ } ) ;
365+
353366 /*
354367
355368 it("it should fetch relation post",function(done){
You can’t perform that action at this time.
0 commit comments