Skip to content
Snippets Groups Projects
Select Git revision
  • 2f7ee7ec2e016106c7f564695334d0541fea4c38
  • main default protected
  • jw_sonar
  • v6.0.0 protected
  • bedran_exercise-list
  • ask-user-to-delete-exercises-on-duplicates
  • update-dependencies
  • jw_sonar_backup
  • add_route_assignments
  • 6.0.0-dev
  • 5.0.1
  • 5.0.0
  • 4.1.0
  • 4.0.0
  • 3.5.3
  • 3.5.2
  • 3.5.1
  • 3.5.0
  • 3.4.2
  • 3.4.1
  • 3.4.0
  • 3.3.0
  • 3.2.0
  • 3.1.3
  • 3.1.2
  • 3.1.1
  • 3.1.0
  • 3.0.1
  • 3.0.0
29 results

Model.ts

Blame
  • Model.ts 572 B
    type Constructor<T> = new (...args: any[]) => T;
    
    
    abstract class Model extends Object {
        static tableName: string = null;
    
        static createFromSql<T extends Object>(this: Constructor<T>, obj: any): T {
            const result = new this();
    
            Object.getOwnPropertyNames(obj).forEach(property => {
                if ( result.hasOwnProperty(property) ) {
                    (result as any)[property] = obj[property];
                }
            });
            return result;
        }
    
        public abstract toJsonObject(lightVersion: boolean): Promise<Object>
    }
    
    
    export default Model;