Skip to content

Commit

Permalink
Added schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Jun 5, 2024
1 parent 6cf1d9c commit 97f696f
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/services/BaseEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,35 @@ export interface IPagedListParams extends IListParams {
count?: boolean;
}

export interface IColumn {
name?: string;
type?: string;
generated?: string;
default?: any;
}

export interface IRelation {
name?: string;
fkName?: string;
relatedName?: string;
isCollection?: boolean;
isInverse?: boolean;

relatedModel?: IModel<any>;
}

export interface IModelSchema {
name: string;
keys: IColumn[];
properties: IColumn[];
relations: IRelation[];
}

export interface IModel<T> {
name: string;
create?(properties?: IClrEntityLike<T>): T;
patch?(original: IClrEntityLike<T>, updates: IClrEntityLike<T>): T;
schema: IModelSchema;
}

export class DefaultFactory {
Expand All @@ -238,7 +263,8 @@ export class Model<T> implements IModel<T> {
constructor(
public name: string,
public readonly keys: string[] = [],
defaults: any = null
defaults: any = null,
public schema = null as IModelSchema
) {
if (defaults) {
this.defaults = [];
Expand Down

0 comments on commit 97f696f

Please sign in to comment.