File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,12 @@ export function getBuild(id: number): Promise<any> {
6464 return run ;
6565 } ) ;
6666
67- build . repository . access_token = build . repository . access_token . token || null ;
67+ if ( build . repository . access_token && build . repository . access_token ) {
68+ build . repository . access_token = build . repository . access_token . token ;
69+ } else {
70+ build . repository . access_token = null ;
71+ }
72+
6873 return build ;
6974 } )
7075 . then ( build => {
Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ export class AccessToken extends Bookshelf.Model<any> {
1616export class Repository extends Bookshelf . Model < any > {
1717 get tableName ( ) { return 'repositories' ; }
1818 get hasTimestamps ( ) { return true ; }
19- builds ( ) { return this . hasMany ( Build , 'repositories_id' ) ; }
2019 access_token ( ) { return this . belongsTo ( AccessToken , 'access_tokens_id' ) ; }
20+ builds ( ) { return this . hasMany ( Build , 'repositories_id' ) ; }
2121}
2222
2323export class Build extends Bookshelf . Model < any > {
Original file line number Diff line number Diff line change @@ -42,12 +42,14 @@ export function getRepository(id: number): Promise<any> {
4242
4343export function getRepositoryOnly ( id : number ) : Promise < any > {
4444 return new Promise ( ( resolve , reject ) => {
45- new Repository ( { id : id } ) . fetch ( { withRelated : [ 'access_token.user ' ] } ) . then ( repo => {
45+ new Repository ( { id : id } ) . fetch ( { withRelated : [ 'access_token' ] } ) . then ( repo => {
4646 if ( ! repo ) {
4747 reject ( repo ) ;
4848 } else {
4949 repo = repo . toJSON ( ) ;
50- repo . access_token = repo . access_token . token || null ;
50+
51+ repo . access_token = repo . access_token && repo . access_token . token ?
52+ repo . access_token . token : null ;
5153
5254 resolve ( repo ) ;
5355 }
You can’t perform that action at this time.
0 commit comments