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 {
3232 name : string ;
3333 entity : string ;
3434 eagerLoad : undefined | Array < string > ;
35+ skipFields : undefined | Array < string > ;
3536
3637 fields ( ) : any ;
3738 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 {
4242 }
4343
4444 /**
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+ *
4648 * @param {string } field
4749 * @returns {boolean }
4850 */
4951 public skipField ( field : string ) {
5052 if ( field . startsWith ( '$' ) ) return true ;
53+ if ( this . baseModel . skipFields && this . baseModel . skipFields . indexOf ( field ) >= 0 ) return true ;
5154
5255 let shouldSkipField : boolean = false ;
5356
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class User extends ORMModel {
2020class Video extends ORMModel {
2121 static entity = 'videos' ;
2222 static eagerLoad = [ 'comments' ] ;
23+ static skipFields = [ 'ignoreMe' ] ;
2324
2425 static fields ( ) {
2526 return {
@@ -28,6 +29,7 @@ class Video extends ORMModel {
2829 title : this . string ( '' ) ,
2930 userId : this . number ( 0 ) ,
3031 otherId : this . number ( 0 ) , // This is a field which ends with `Id` but doesn't belong to any relation
32+ ignoreMe : this . string ( '' ) ,
3133 user : this . belongsTo ( User , 'userId' ) ,
3234 comments : this . morphMany ( Comment , 'subjectId' , 'subjectType' )
3335 } ;
You can’t perform that action at this time.
0 commit comments