UNPKG

vue-service-model

Version:

Vue.js library for handling REST service requests with caching, aggregation and model definitions

81 lines (80 loc) 2.35 kB
import Dictionary from '../types/Dictionary'; import { BaseClass } from '../utils/BaseClass'; import { Field } from '../fields/Field'; import { PrimaryKey } from '../types/models/ModelManager'; /** * BaseModel class */ export declare class BaseModel extends BaseClass { /** * Field definitions for current model * e.g: * {id: new UUIDField(), name: new CharField()} */ protected static fieldsDef: Dictionary<Field>; /** * Flag whether model has be registered or not */ private static __modelRegistered; /** * Getter to simulate static class property with fixed inheritance */ protected static get _modelRegistered(): boolean; /** * Setter to simulate static class property with fixed inheritance */ protected static set _modelRegistered(v: boolean); /** * Model data */ protected _data: Dictionary<any>; /** * Bound field objects of model */ protected _fields: Dictionary<Field>; /** * Constructor * @param data Model data */ constructor(data?: Dictionary<any>); /** * Data containing values */ get data(): Dictionary<any>; set data(value: Dictionary<any>); /** * Bound dictionary of fields by field name */ get fields(): Dictionary<Field>; /** * Getter with values to return data of model * Can be accessed as object (e.g. for field name 'description': val.description) */ get val(): Dictionary<any>; /** * Return primary key of model instance or null if not set */ get pk(): PrimaryKey | null; /** * Return unbound static field by name. * Throws NotDeclaredFieldException if field name is not in fields */ static getField(fieldName: string): Field; /** * Return field by name. * Throws NotDeclaredFieldException if field name is not in fields */ getField(fieldName: string): Field; /** * Return primary key field or null of no primary key field exists */ getPrimaryKeyField(): Field | null; /** * Bind fields from fieldsDef to _fields */ protected _bindFields(): void; /** * Register model to perform unique actions */ static register(): boolean; }