File tree Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export interface ORMModel {
32
32
name : string ;
33
33
entity : string ;
34
34
eagerLoad : undefined | Array < string > ;
35
+ skipFields : undefined | Array < string > ;
35
36
36
37
fields ( ) : any ;
37
38
dispatch ( name : string , ...params : Array < any > ) : any ;
Original file line number Diff line number Diff line change @@ -42,12 +42,15 @@ export default class Model {
42
42
}
43
43
44
44
/**
45
- * Tells if a field should be ignored. This is true for fields that start with a `$` and all foreign keys
45
+ * Tells if a field should be ignored. This is true for fields that start with a `$` or is it is within the skipField
46
+ * property.
47
+ *
46
48
* @param {string } field
47
49
* @returns {boolean }
48
50
*/
49
51
public skipField ( field : string ) {
50
52
if ( field . startsWith ( '$' ) ) return true ;
53
+ if ( this . baseModel . skipFields && this . baseModel . skipFields . indexOf ( field ) >= 0 ) return true ;
51
54
52
55
let shouldSkipField : boolean = false ;
53
56
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class User extends ORMModel {
20
20
class Video extends ORMModel {
21
21
static entity = 'videos' ;
22
22
static eagerLoad = [ 'comments' ] ;
23
+ static skipFields = [ 'ignoreMe' ] ;
23
24
24
25
static fields ( ) {
25
26
return {
@@ -28,6 +29,7 @@ class Video extends ORMModel {
28
29
title : this . string ( '' ) ,
29
30
userId : this . number ( 0 ) ,
30
31
otherId : this . number ( 0 ) , // This is a field which ends with `Id` but doesn't belong to any relation
32
+ ignoreMe : this . string ( '' ) ,
31
33
user : this . belongsTo ( User , 'userId' ) ,
32
34
comments : this . morphMany ( Comment , 'subjectId' , 'subjectType' )
33
35
} ;
You can’t perform that action at this time.
0 commit comments